Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!decprl!decprl!boyd From: boyd@prl.dec.com (Boyd Roberts) Newsgroups: comp.unix.wizards Subject: Re: Signals and context switches Message-ID: <1991Jun18.103934.25635@prl.dec.com> Date: 18 Jun 91 10:39:34 GMT References: <1991Jun16.010626.28257@bnlux1.bnl.gov> <1991Jun17.085558.16652@prl.dec.com> <1991Jun17.131027.8700@bnlux1.bnl.gov> Sender: news@prl.dec.com (USENET News System) Organization: Digital Equipment Corporation - Paris Research Laboratory Lines: 46 Nntp-Posting-Host: prl313.prl.dec.com In article <1991Jun17.131027.8700@bnlux1.bnl.gov>, drs@bnlux1.bnl.gov (David R. Stampf) writes: > > There is virtually no load - it is a sun ipc with only myself on > and running. I guess I'm amazed that the time quanta is as large as 1 > second. No load. Ok. > > > I recieved a few suggestions to go to sleep rather than > while(1);, which suprisingly didn't work! What we had thought was that > by calling kill, we would force a context switch. That obvivously does > not happen. What *did* work was to call select without any file > descriptors, but with a miniscule timeout. That seemed to force the > switch. I'm still puzzled by sleep's failure. > Run that by me again. There was `no load' but you had a process going? while(1); What we have here is a `compute bound process[es] doing no I/O'. This will really screw up signal delivery. Signals are delivered: - when a process is re-scheduled (ie. goes from runnable to actually running) - after a process takes an exception (CPU generated trap) - at the end of a system call So, if all that's happening is the first case, then you could be waiting a long time. To, wait without doing anything use pause(2). If you have select(2), why not get the process to write you a message? Down a pipe, socket, pty, whatever. Using signals is just _such_ a bad idea. Whatever you do, don't have the select(2) polling every small time t. Boyd Roberts boyd@prl.dec.com ``When the going gets wierd, the weird turn pro...''