|
@@ -12,7 +12,7 @@ CONST Maximum* = MAX (SET) - MIN (SET) + 1;
|
|
|
VAR count-: SIZE;
|
|
|
|
|
|
VAR affinityMask: SET;
|
|
|
-VAR event: Kernel32.HANDLE;
|
|
|
+VAR semaphore: Kernel32.HANDLE;
|
|
|
VAR thread: ARRAY Maximum OF Kernel32.HANDLE;
|
|
|
|
|
|
(** Returns the unique index of the processor executing this procedure call. *)
|
|
@@ -22,14 +22,13 @@ PROCEDURE GetCurrentIndex- EXTERN "Activities.GetCurrentProcessorIndex" (): SIZE
|
|
|
(** A suspended processor must be resumed by a call to the ResumeAnyProcessor procedure. *)
|
|
|
PROCEDURE SuspendCurrentProcessor-;
|
|
|
BEGIN {UNCOOPERATIVE, UNCHECKED}
|
|
|
- ASSERT (Kernel32.WaitForSingleObject (event, Kernel32.Infinite) # Kernel32.WaitFailed);
|
|
|
+ ASSERT (Kernel32.WaitForSingleObject (semaphore, Kernel32.Infinite) # Kernel32.WaitFailed);
|
|
|
END SuspendCurrentProcessor;
|
|
|
|
|
|
(** Resumes the execution of all suspended processors. *)
|
|
|
PROCEDURE ResumeAllProcessors-;
|
|
|
BEGIN {UNCOOPERATIVE, UNCHECKED}
|
|
|
- ASSERT (Kernel32.SetEvent (event) # 0);
|
|
|
- ASSERT (Kernel32.ResetEvent (event) # 0);
|
|
|
+ ASSERT (Kernel32.ReleaseSemaphore (semaphore, Maximum, NIL) # 0);
|
|
|
END ResumeAllProcessors;
|
|
|
|
|
|
(** Starts the execution of all available processors. *)
|
|
@@ -58,8 +57,8 @@ END Start;
|
|
|
PROCEDURE Initialize-;
|
|
|
VAR systemAffinityMask: SET; i: SIZE; handle: Kernel32.HANDLE;
|
|
|
BEGIN {UNCOOPERATIVE, UNCHECKED}
|
|
|
- event := Kernel32.CreateEvent (NIL, Kernel32.True, Kernel32.False, NIL);
|
|
|
- ASSERT (event # Kernel32.InvalidHandleValue);
|
|
|
+ semaphore := Kernel32.CreateSemaphore (NIL, 0, MAX (SIZE), NIL);
|
|
|
+ ASSERT (semaphore # Kernel32.InvalidHandleValue);
|
|
|
|
|
|
ASSERT (Kernel32.GetProcessAffinityMask (Kernel32.GetCurrentProcess (), ADDRESS OF affinityMask, ADDRESS OF systemAffinityMask) # 0);
|
|
|
|
|
@@ -94,7 +93,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
|
|
|
ASSERT (Kernel32.CloseHandle (thread[i]) # 0);
|
|
|
END;
|
|
|
END;
|
|
|
- ASSERT (Kernel32.CloseHandle (event) # 0);
|
|
|
+ ASSERT (Kernel32.CloseHandle (semaphore) # 0);
|
|
|
END Terminate;
|
|
|
|
|
|
END Processors.
|