[comp.lang.modula2] Context switching using Logitec 3.03 question

klarich@a.cs.okstate.edu (Terry Klarich) (09/23/89)

I would be interested in hearing from anyone who can help me to understand
how to do a context switch between two processes via an interrupt service 
procedure.  What I would like to do is to allow more than one process to
share cpu time.  I tried installing 'TRANSFER(p1,p2);' in the code of an
interrupt handler ;but, this didn't work.  It would switch one time and
when the clock ticked again, I would have to hit the reset button.  I know
the real solution is to get Unix and go from there.  If anyone has done
this or knows how, please let me hear from you.

MARKV@UKANVAX ("MARK GOODERUM - UNIV. OF KANSAS ACS - MARKV@UKANVAX") (09/24/89)

Hmm, you might try a hint or two from the oldest micro-computer operating
system, Amiga OS.

When the Amiga Exec (the top level manager in the OS) switches a task,
it saves the full register set from the old task, loads the new register
set for the task it is switching to, and then jumps to execution at the
point where it left off in the new task.  It should be noted that this
is 68000 family processor but the same technique should work for the
80XX family.  (This technique IS used in a 'semi' multitasking library
for the PC I use at work.)  Some M2 systems even provide some low level
calls like SAVEREGS and LOADREGs to make this easier.

One important point is for this approach to work properly, each task must
have it's own stack and it's own copy of local variables.  In M2 the
latter is a given (usually), but the former can take some juggling.

-Mark Gooderum
 MARKV@UKANVAX