Subject: Re: race in sleep.
To: Paul Kranenburg <email@example.com>
From: John Birrell <firstname.lastname@example.org>
Date: 10/17/1995 10:21:49
> I just changed libc/gen/[u]sleep.c to be less susceptible to SIGALRMs
> coming in too late when other signal handlers are also active.
> I also realized that the change makes another race possible:
> a previous SIGALRM handler might now miss a signal because the sihnal mask
> is reset earlier. I can't see a way out of this without adding one more
> system call (to the eight which are already there as smartly pointed out
> by th eman-page).
For me it would be nice if [u]sleep didn't need to fiddle with signal handlers
at all. We often strike this sort of thing on systems which don't have a
nanosleep() function. We use a call to select() specifying the timeout value,
but with nfds set to zero. Then you only need one syscall to do the timeout,
but you need a gettimeofday() call before and after to find out how long you
slept. So that's 3 syscalls vs 8 and no race condition. 8-).
BTW, while you're working on sleepy things, how about adding a nanosleep, then
changing both usleep and sleep to call that?
John Birrell CIMlogic Pty Ltd
email@example.com 119 Cecil Street
Ph +61 3 9690 9600 South Melbourne Vic 3205
Fax +61 3 9690 6650 Australia
Mob +61 18 353 137