|
StuBS
|
Synchronizes the kernel with interrupts using the Prologue/Epilogue Model. More...
Functions | |
| Guarded | enter () |
| Entering the critical section from level 0. | |
| void | leave () |
| Leaving the critical section. | |
| void | relay (Epilogue handler) |
| A prologue wants its epilogue to be processed (entering from level 1). | |
| const Vault & | unsafeConstAccess () |
| Access the epilogue vault without taking the lock. Beware race conditions! | |
Synchronizes the kernel with interrupts using the Prologue/Epilogue Model.
The Guard is used to synchronize between "normal" core activities (currently just the text output, later system calls) and interrupt handling routines. For this purpose, Guard has to contain one ore more queues, in which Epilogue functions can be added. This is necessary if the critical section is occupied at the time when an interrupt occurs, and the Epilogue cannot be executed immediately. The queued epilogues are processed when leaving the critical section.
Hints:
| Guarded Guard::enter | ( | ) |
Entering the critical section from level 0.
Entering the critical section has to be handled differently depending on the system: In a single-core system it is sufficient to mark the entry by just setting a flag variable (since only one control flow can enter the critical section at the same time). However, as soon as there are multiple cores, this is no longer the case. If a core wants to enter the critical section while another core is already in there, it should (actively) wait in this method until the critical area is released again.
| void Guard::leave | ( | ) |
| void Guard::relay | ( | Epilogue | handler | ) |
A prologue wants its epilogue to be processed (entering from level 1).
This method is called by the interrupt handlers. Whether the passed epilogue is executed immediately or it just enqueued to the epilogue queue depends on whether the critical section on this Core is accessible or not.