home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.wizards:3765 comp.unix.questions:10629
- Newsgroups: comp.unix.wizards,comp.unix.questions
- Path: sparky!uunet!munnari.oz.au!uniwa!DIALix!zeus!peter
- From: peter@zeus.dialix.oz.au (Peter Wemm)
- Subject: Re: reliable signals under BSD / SVR4
- Message-ID: <Btwqvs.LAI@zeus.dialix.oz.au>
- Keywords: signals, reliable, software interrupts
- Organization: Karam Pty. Ltd. Perth, Australia
- References: <acourtny.715263267@unix1.tcd.ie>
- Date: Tue, 1 Sep 1992 16:23:52 GMT
- Lines: 58
-
- acourtny@unix1.tcd.ie (Antony A. Courtney) writes:
-
- >I wrote the following short program to test whether or not signals are reliable
- >on our particular SVR4 implementation (A Siemens-Nixdorf RM600 running Sinix).
-
- >The particular implementation of signal() is from Stevens' "Advanced Programming
- >in the UNIX environment".
-
- >The program simply installs a signal handler for SIGUSR1, fork()s, and the
- >parent sends 20 SIGUSR1 signals to the child as fast as it can. The child
- >has a busy loop in the signal handler to make it deliberately slow. The result
- >is that I only catch a random subset of the signals posted (sometimes I don't
- >catch any, other times I get 2 or 3). I get similar behavior under 4.3BSD if
- >I use BSD's implementation of signal(), which is supposedly "reliable".
-
- >What's the word? Are signals "reliable" or aren't they?
-
- >I admit I haven't read *every* single standard written about all the various
- >implementations and semantics of signals; that would probably take more time
- >than writing a reliable signal implementation!
-
- >Code follows, thanks for any help...
-
- > -antony
-
- >--
- >******************************************************************************
- >* Antony A. Courtney Email: acourtny@unix1.tcd.ie *
- >* Computer Science Department antony@george.lbl.gov *
- >* Trinity College, Dublin, Ireland Phone: 01+353+1-607389 *
-
- [code deleted for brevity]
-
- Isn't the point of reliable signals to make sure that the handler is
- always valid, and there are no "danger" windows while the signal
- handler is set to SIG_DFL?
-
- In "old" unix, when a signal was posted, the handler was called, and the
- signal handler vector was reset to SIG_DFL. If another signal followed
- afterwards, it could potentially kill the process. The handler could
- re-arm the signal vector to point back to itself, but there is a danger
- window between the start of the handler and the re-arming.
-
- BSD/POSIX/SVR4 signals to not automatically "reset" to default on
- actication, and the signal is usually *masked* to prevent a recurring
- signal from within the handler. The mask is cleared when the handler
- returns. I dont seem to remember anything about reliable stacking or
- queueing of signals in this model. I think this is implemented
- in the kernel as a bitmask, so at theoretically one of each signal could
- be queued up. I'm not sure about other implementations (other than
- SVR4/386, that is...).
-
- Sigaction can be set to do many wonderful things though...
- --
- Peter Wemm : peter@zeus.dialix.oz.au If it's broke, fix it (The MS-DOS way)
- Work phone: +61-9-479-1855 If it aint broke, don't touch it (The Unix way)
- Fax: +61-9-479-1134 If we can't fix it, it ain't broke (Maintainer's Motto)
- "Don't give me that intelligent life cr*p, find me something to blow up!"
-