...
Panel | ||||
---|---|---|---|---|
| ||||
Panel | ||
---|---|---|
| ||
(1) Task H and Task M are both waiting for an event to occur and Task L is executing. (2) At some point, Task L acquires a semaphore, which it needs before it can access a shared resource. (3) Task L performs operations on the acquired resource. (4) The event that Task H was waiting for occurs, and the kernel suspends Task L and start executing Task H since Task H has a higher priority. (5) Task H performs computations based on the event it just received. (6) Task H now wants to access the resource that Task L currently owns (i.e., it attempts to get the semaphore that Task L owns). Because Task L owns the resource, Task H is placed in a list of tasks waiting for the semaphore to be available. (7) Task L is resumed and continues to access the shared resource. (8) Task L is preempted by Task M since the event that Task M was waiting for occurred. (9) Task M handles the event. (10) When Task M completes, the kernel relinquishes the CPU back to Task L. (11) Task L continues accessing the resource. (12) Task L finally finishes working with the resource and releases the semaphore. At this point, the kernel knows that a higher-priority task is waiting for the semaphore, and a context switch takes place to resume Task H. (13) Task H has the semaphore and can access the shared resource. |
...