Interrupting a Round Robin Dispatcher

Chris Torek chris at mimsy.UUCP
Sun Mar 12 17:38:51 AEST 1989


In article <321 at h.cs.wvu.wvnet.edu> dymm at 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 at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list