home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
ddjmag
/
ddj8802.arc
/
LINDLEY.ARC
/
LINDLEY.LS4
< prev
next >
Wrap
Text File
|
1980-01-01
|
3KB
|
88 lines
Listing Four: Changes to the multitasking kernel
CONST
task_stack_size = 1000;
PROCEDURE Yield;
{This version in assembly language for}
{speed. See original version for comments.}
BEGIN
IF cp^.link <> cp THEN {must have more than}
{one task forked to be}
{able to yield}
BEGIN
INLINE($C6/$06/child_process/$00/
{child_process is false}
$C4/$3E/cp/ {les di,[cp]}
$89/$E0/ {mov ax,sp}
$05/$02/$00/ {add ax,2}
$26/ {es:}
$89/$45/$04/ {mov [di+4],ax}
$26/ {es:}
$C6/$45/$06/$00/ {mov byte ptr [di+6],0}
$89/$FB/ {L1: mov bx,di}
$26/ {es:}
$C4/$1F/ {les bx,[bx]}
$26/ {es:}
$80/$7F/$06/$00/ {cmp byte ptr [bx+6],0}
$74/$04/ {je L2}
$89/$DF/ {mov di,bx}
$EB/$F0/ {jmp L1}
$89/$1E/cp/ {L2: mov [cp],bx}
$8C/$06/cp+2/ { mov [cp+2],es}
$26/ {es:}
$C6/$47/$06/$02/ {mov byte ptr [bx+6],2}
$26/ {es:}
$8B/$6F/$04); {mov bp,[bx+4]}
END
ELSE
BEGIN
writeln('Cannot yield only single task running');
halt;
END;
END;
PROCEDURE Wait; {put current task in wait mode}
{until a send makes it ready}
BEGIN
IF cp^.link <> cp THEN {must have more than}
{one task forked to be}
{able to wait}
BEGIN
waitfor^ := cp; {waitfor points at the}
{current task}
INLINE($C6/$06/child_process/$00/
{child_process is false}
$C4/$3E/cp/ {les di,[cp]}
$89/$E0/ {mov ax,sp}
$05/$02/$00/ {add ax,2}
$26/ {es:}
$89/$45/$04/ {mov [di+4],ax}
$26/ {es:}
$C6/$45/$06/$01/ {mov byte ptr [di+6],1}
$89/$FB/ {L1: mov bx,di}
$26/ {es:}
$C4/$1F/ {les bx,[bx]}
$26/ {es:}
$80/$7F/$06/$00/ {cmp byte ptr [bx+6],0}
$74/$04/ {je L2}
$89/$DF/ {mov di,bx}
$EB/$F0/ {jmp L1}
$89/$1E/cp/ {L2: mov [cp],bx}
$8C/$06/cp+2/ { mov [cp+2],es}
$26/ {es:}
$C6/$47/$06/$02/ {mov byte ptr [bx+6],2}
$26/ {es:}
$8B/$6F/$04); {mov bp,[bx+4]}
END
ELSE
BEGIN
writeln('Cannot wait only single task running');
halt;
END;
END;