Xref: utzoo comp.unix.questions:12177 comp.unix.wizards:15039 Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Interrupting a Round Robin Dispatcher Message-ID: <16354@mimsy.UUCP> Date: 12 Mar 89 07:38:51 GMT References: <321@h.cs.wvu.wvnet.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 31 In article <321@h.cs.wvu.wvnet.edu> dymm@b.cs.wvu.wvnet.edu (David Dymm) writes: >... When the dispatcher comes back to the interrupted task, it will >"longjmp" to the end (IS THIS CORRECT??) If you mean `using the function longjmp() found in the C library', the answer is `no'. If you try this under 4.2BSD or 4.3BSD (by which I mean `4.2BSD or 4.3BSD', not `SunOS', nor any other system *derived from* 4.2BSD, although it *may* still happen there), you will get a `longjmp botch' and a core dump. >of the alarm_handler which will do a "return (0)", and cause the >dispatcher to pick up from where it left off when the task >was interrupted. It is possible (although difficult and nonportable) to do what you have described (a variant of coroutines), but you cannot use longjmp(), as it is restricted to jumping `upward' in the stack (assuming the stack grows downward). Coroutines jump upward half the time and downward half the time. (Well, close enough. :-) ) In addition, it is necessary to reserve sufficient stack space to each task so that no one task will write over another. How much space is required depends upon the tasks. Most existing 4BSD and SysV implementations will not help you detect collisions. Under operating systems that let you protect individual pages in different ways, you can make an inaccessible `red zone' below each task stack. SunOS 4.x should be able to do this. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris