StuBS
|
The Watch device deals with timer interrupts. More...
#include <watch.h>
Public Member Functions | |
bool | windup (uint32_t us) |
Windup / initialize. More... | |
bool | prologue () override |
Prologue of timer interrupts. More... | |
void | epilogue () override |
Epilogue of timer interrupts. More... | |
uint32_t | interval () const |
Retrieve the interrupt interval. More... | |
void | activate () const |
Activate the timer on this core. More... | |
void | block_if_possible () |
Blocks the timer interrupts on this core if no bells are pending. More... | |
void | unblock () |
Allow the previously blocked timer interrupts on this core. More... | |
Public Member Functions inherited from Gate | |
Gate () | |
Constructor. | |
virtual | ~Gate () |
Destructor. More... | |
virtual bool | prologue ()=0 |
Device-specific interrupt handling routine that is executed immediately after the interrupt occurs (asynchronously). More... | |
virtual void | epilogue () |
Possibly delayed, synchronously executed Device-specific interrupt handling routine. | |
The Watch device deals with timer interrupts.
Handles LAPIC::Timer interrupts, therefore managing the time slices and triggering a thread switch if necessary.
void Watch::activate | ( | ) | const |
Activate the timer on this core.
The core local timer starts with the interval previously configured in windup(). To get timer interrupts on all cores, this method must be called once per core (however, it is sufficient to call windup only once since the APIC-Bus frequency is the same on each core).
void Watch::block_if_possible | ( | ) |
Blocks the timer interrupts on this core if no bells are pending.
The LAPIC Timer can be masked with LAPIC::Timer::setMasked as soon as no thread is ready and no Bell is waiting to be counted down. block_if_possible() and unblock() must be called from the idle loop.
|
overridevirtual |
Epilogue of timer interrupts.
Triggers the thread switch and checks the Bellringer.
Reimplemented from Gate.
uint32_t Watch::interval | ( | ) | const |
Retrieve the interrupt interval.
|
overridevirtual |
Prologue of timer interrupts.
true
if the Watch::epilogue should be executed. Implements Gate.
void Watch::unblock | ( | ) |
Allow the previously blocked timer interrupts on this core.
Logical counterpart to Watch::block(). Allows the delivery of core local timer interrupts again.
bool Watch::windup | ( | uint32_t | us | ) |
Windup / initialize.
Assigns itself to the Plugbox and initializes the LAPIC::Timer in such a way that regular interrupts are triggered approx. every us
microseconds when Watch::activate() is called. For this purpose, a suitable timer divisor is determined based on the timer frequency determined with LAPIC::Timer::ticks(). This timer divisor has to be as small as possible, but large enough to prevent the 32bit counter from overflowing.
us | Desired interrupt interval in microseconds. |