Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.bugs.sys5 Subject: Sleep (was Re: What's a system call) Message-ID: <938@twwells.uucp> Date: 23 May 89 02:29:53 GMT References: <3759@sugar.hackercorp.com] <10156@smoke.BRL.MIL] <1153@aplcen.apl.jhu.edu] <1350@frog.UUCP] <11506@ulysses.homer.nj.att.com] <913@twwells.uucp] <1232@netcom.UUCP> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 43 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <1232@netcom.UUCP> chris@netcom.UUCP (Chris Lakewood) writes: : In article <913@twwells.uucp] bill@twwells.UUCP (T. William Wells) writes: : ]And then consider sleep(). I know of one system where sleep was : ]implemented as a system call (and documented in section 2) because : ]the standard version of sleep would hang occasionally. Consider: : ] : ] alarm(n); : ] pause(); : ] : ](the guts of sleep) and what happens if the process doesn't run for n : ]seconds. Have you ever had tail hang on a heavily loaded system? (I : ]have.) Guess why. : ]--- : ]Bill { uunet | novavax } !twwells!bill : : Don't leave us in suspense... What happens if the process doesn't run for : n seconds? Actually, the process won't run for at least n seconds unless : it receives some signal. The pause causes the process to block until a : signal is received. Here's some suspense: alarm(n); pause(); The problem is that, in order for alarm to work reliably with pause, the alarm must be prevented from occuring before the pause executes. Since there wasn't an atomic method of doing this, sleep could hang. Another way to fix this would have been to have the signal handler do a long jump, but I suspect that this would have caused problems of its own. (Sorry for the delay in answering. And also if someone has already answered this: my newsfeed backed up a week and they "fixed" the problem by tossing a week of news! Argh.) --- Bill { uunet | novavax } !twwells!bill