Category : Modula II Source Code
Archive   : TASKING.ZIP
Filename : LOCKS.MOD

 
Output of file : LOCKS.MOD contained in archive : TASKING.ZIP
IMPLEMENTATION MODULE Locks;

FROM SYSTEM IMPORT ADDRESS, ADR, SETREG, GETREG, CODE, AX, BX, DS;
FROM Tasks IMPORT NextTask;

TYPE
LockType = BOOLEAN;

PROCEDURE Lock(VAR l: LockType);
BEGIN
WHILE BusyLock(l) DO NextTask END;
END Lock;

PROCEDURE BusyLock(VAR l: LockType): BOOLEAN; (* test and set *)
VAR
lckadd: ADDRESS;
oldlock: BOOLEAN;
BEGIN
lckadd := ADR(l);
SETREG(AX, ORD(TRUE));
SETREG(BX, lckadd.OFFSET);
SETREG(DS, lckadd.SEGMENT);
CODE(
086H, (* XCHG *)
007H); (* al,[BX] *)
GETREG(AX, oldlock);
RETURN oldlock;
END BusyLock;

PROCEDURE Unlock(VAR l: LockType); (* also serves for Init *)
BEGIN
l := FALSE;
END Unlock;

END Locks.


  3 Responses to “Category : Modula II Source Code
Archive   : TASKING.ZIP
Filename : LOCKS.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/