If the system executes an idle step, it is in a stationary condition. At this point, the main task releases the CPU by calling a system service that blocks it from running until some external stimulus occurs. The external stimulus can be either an event/data change, or a timeout.
The decision whether to enter a wait state or not should be handled carefully, since once the main task blocks itself, only external input will wake it. Therefore, the
pr_pause
procedure that actually blocks the cannot be uninterrupted to prevent the following scenario:This scenario leads to a deadlock condition. Since the timeout is ignored by the system, the main task has already “decided” to hibernate itself but has not yet done so and the “wake” call is lost. The pr_pause procedure will apply the test-and-wait in a mutually exclusive manner.
The
pr_pause
procedure will be discussed later, since it is dependent on the underlying operating system.