Understanding interrupted system calls
Joe Marcus Clarke
marcus at FreeBSD.org
Wed Sep 12 13:32:51 PDT 2007
On Sun, 2007-09-02 at 14:17 +1000, Bruce Evans wrote:
> >From Jilles' previous reply:
>
> >>> The problem seems to be the following code in
> >>> src/sys/dev/syscons/syscons.c, in case VT_WAITACTIVE in scioctl():
> >>>
> >>> while ((error=tsleep(&scp->smode, PZERO|PCATCH,
> >>> "waitvt", 0)) == ERESTART) ;
> >>>
> >>> If a signal is caught and system call restart is enabled for that
> >>> signal, this makes it spin in a tight loop, waiting in vain for the
> >>> signal to go away. The idea of ERESTART is that the syscall function
> >>> returns it and then the signal handler is entered. If and when the
> >>> signal handler returns, it will return to the system call instruction,
> >>> restarting it (perhaps this is optimized to avoid the switch to userland
> >>> and back). With EINTR, the signal handler would return to directly
> >>> after the system call instruction.
> >>>
> >>> The fixed version would then be
> >>>
> >>> error = tsleep(&scp->smode, PZERO|PCATCH, "waitvt", 0);
>
> I think this is right. The kernel should never loop on ERESTART like this.
> Please fix the remaining style bug in it (missing spaces around binary
> operator).
Bruce, I didn't know if you saw my fix, if it needs more work, or if
you're going to commit it? I'd really like to get this fixed before
7.0. Should I open a PR to track it? Thanks.
http://www.marcuscom.com/downloads/syscons.c.diff
http://www.marcuscom.com/downloads/pcvt_ext.c (-STABLE only)
Joe
--
Joe Marcus Clarke
FreeBSD GNOME Team :: gnome at FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20070912/05b67c13/attachment.pgp
More information about the freebsd-arch
mailing list