StuBS
Watch Class Reference

The Watch device deals with timer interrupts. More...

#include <device/watch.h>

Inheritance diagram for Watch:
[legend]
Collaboration diagram for Watch:
[legend]

Public Member Functions

 Watch ()
 
bool windup (uint32_t us)
 Windup / initialize.
 
bool prologue () override
 Prologue of timer interrupts.
 
void epilogue () override
 Epilogue of timer interrupts.
 
uint32_t interval () const
 Retrieve the interrupt interval.
 
void activate () const
 Activate the timer on this core.
 
- Public Member Functions inherited from Gate
 Gate ()
 Constructor.
 
virtual ~Gate ()
 Destructor.
 
bool is_queued () const
 Status about the epilogue.
 
void set_queued (bool val)
 Set epilogue status.
 

Private Member Functions

 Watch (const Watch &)=delete
 
Watchoperator= (const Watch &)=delete
 

Private Attributes

uint32_t interv
 
uint32_t ticks
 
uint32_t div
 

Additional Inherited Members

- Protected Member Functions inherited from Queue< T, ContainerType >::Node
 Node ()
 

Detailed Description

The Watch device deals with timer interrupts.

Handles LAPIC::Timer interrupts, therefore managing the time slices and triggering a thread switch if necessary.

Constructor & Destructor Documentation

◆ Watch() [1/2]

Watch::Watch ( const Watch )
privatedelete

◆ Watch() [2/2]

Watch::Watch ( )
inline

Member Function Documentation

◆ operator=()

Watch & Watch::operator= ( const Watch )
privatedelete

◆ windup()

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. However, the LAPIC::Timer is not armed until Watch::activate() is called. Hence, Watch::windup() just sets up all the values. 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.

Parameters
usDesired interrupt interval in microseconds.
Returns
Indicates if the interval could be set.
Todo:
Implement Method

◆ prologue()

bool Watch::prologue ( )
overridevirtual

Prologue of timer interrupts.

Returns
true if the Watch::epilogue should be executed.
Todo:
Implement Method

Implements Gate.

◆ epilogue()

void Watch::epilogue ( )
overridevirtual

Epilogue of timer interrupts.

Triggers the thread switch.

Todo:
Implement Method

Reimplemented from Gate.

◆ interval()

uint32_t Watch::interval ( ) const

Retrieve the interrupt interval.

Returns
Interval in microseconds
Todo:
Implement method

◆ activate()

void Watch::activate ( ) const

Activate the timer on this core.

Activate the LAPIC::Timer using LAPIC::Timer::set(). 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).

Todo:
Implement method

Member Data Documentation

◆ interv

uint32_t Watch::interv
private

◆ ticks

uint32_t Watch::ticks
private

◆ div

uint32_t Watch::div
private

The documentation for this class was generated from the following files: