--- Processes.mod 2016-03-17 17:07:30.000000000 +0100 +++ /home/georg/GM2/gcc-4.7.4+gm2-git-latest/gm2/gcc-versionno/gcc/gm2/gm2-libs-iso/Processes.mod 2016-03-12 16:00:13.064542358 +0100 @@ -229,15 +229,27 @@ PROCEDURE Reschedule ; VAR - p, - best, + p: ProcessId; + best: ProcessId ; head: ProcessId ; + a: ProcessId; + b: ProcessId; + test:BOOLEAN; BEGIN checkDead ; IF pQueue[ready]^.right=pQueue[ready] THEN (* only one process on the ready queue, don't bother searching *) - Assert(currentId=pQueue[ready]) ; + a:=currentId; + b:=pQueue[ready]; + test:=a=b; + IF test + THEN (* Nothing to do, the only runable process is already running. *) + ELSE (* can happen if switching processes. The currently running process is already out of the queue. *) + currentId:=b; + TRANSFER(a^.context, currentId^.context); + END; + (* Assert(test) ;*) RETURN ELSE head := pQueue[ready] ; @@ -283,8 +295,8 @@ NEWCOROUTINE(procBody, stack, workSpace, context) ; params := procParams ; state := passive ; - right := NIL ; - left := NIL + right := procId ; + left := procId END ; OnPassiveQueue(procId) END Create ; @@ -300,7 +312,7 @@ procParams: Parameter; VAR procId: ProcessId) ; BEGIN Create(procBody, extraSpace, procUrg, procParams, procId) ; - Activate(procId) + doActivate(procId,procParams) END Start ; @@ -556,8 +568,8 @@ context := CURRENT() ; params := NIL ; state := passive ; - right := NIL ; - left := NIL + right := currentId ; + left := currentId END ; OnReadyQueue(currentId) END setupCurrentId ;