The Pedigree Project 0.1
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
IntervalTimer Class Reference
+ Inheritance diagram for IntervalTimer:
+ Collaboration diagram for IntervalTimer:

Public Types

enum  Mode { Hardware = 0 , Virtual , Profile }
 

Public Member Functions

 IntervalTimer (PosixProcess *pProcess, Mode mode=Hardware)
 
void setInterval (Time::Timestamp interval, Time::Timestamp *prevInterval=nullptr)
 
void setTimerValue (Time::Timestamp value, Time::Timestamp *prevValue=nullptr)
 Set the current value of the timer.
 
void setIntervalAndValue (Time::Timestamp interval, Time::Timestamp value, Time::Timestamp *prevInterval=nullptr, Time::Timestamp *prevValue=nullptr)
 Set both interval and value atomically.
 
void disarm ()
 
void getIntervalAndValue (Time::Timestamp &interval, Time::Timestamp &value)
 
void consumeCpuTime (Time::Timestamp absoluteTotal)
 
Time::Timestamp getInterval () const
 
Time::Timestamp getValue () const
 

Private Member Functions

virtual void timer (uint64_t delta)
 
Time::Timestamp absoluteTotal () const
 
bool advanceTimeLocked (Time::Timestamp absoluteTotal)
 
void armHardwareLocked ()
 
void setArmedLocked (bool armed)
 
void signal ()
 

Private Attributes

PosixProcess * m_Process
 
Mode m_Mode
 
Time::Timestamp m_Value
 
Time::Timestamp m_Interval
 
Time::Timestamp m_LastTotal
 
Spinlock m_Lock
 
bool m_Armed
 
Timer * m_pTimer
 

Detailed Description

Definition at line 57 of file PosixProcess.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Hardware 

Hardware-backed timer (wall time).

Virtual 

CPU time in user mode only.

Profile 

CPU time in user and system.

Definition at line 59 of file PosixProcess.h.

Constructor & Destructor Documentation

◆ IntervalTimer()

IntervalTimer::IntervalTimer ( PosixProcess *  pProcess,
Mode  mode = Hardware 
)

Setting hw=true will use hardware. hw=false requires adjust() to be called to be able to trigger timers.

Definition at line 172 of file PosixProcess.cc.

References Machine::getTimer(), and Hardware.

◆ ~IntervalTimer()

IntervalTimer::~IntervalTimer ( )
virtual

Definition at line 192 of file PosixProcess.cc.

Member Function Documentation

◆ absoluteTotal()

Time::Timestamp IntervalTimer::absoluteTotal ( ) const
private

Definition at line 304 of file PosixProcess.cc.

◆ advanceTimeLocked()

bool IntervalTimer::advanceTimeLocked ( Time::Timestamp  absoluteTotal)
private

Definition at line 317 of file PosixProcess.cc.

◆ armHardwareLocked()

void IntervalTimer::armHardwareLocked ( )
private

Definition at line 327 of file PosixProcess.cc.

◆ consumeCpuTime()

void IntervalTimer::consumeCpuTime ( Time::Timestamp  absoluteTotal)

Advances a CPU timer to a monotonic absolute process-time snapshot.

Definition at line 288 of file PosixProcess.cc.

References Hardware, and signal().

Referenced by PosixProcess::reportTimesUpdated().

+ Here is the caller graph for this function:

◆ disarm()

void IntervalTimer::disarm ( )

Disarms without delivering an expiry during process teardown.

Definition at line 261 of file PosixProcess.cc.

Referenced by PosixProcess::processTerminated().

+ Here is the caller graph for this function:

◆ getInterval()

Time::Timestamp IntervalTimer::getInterval ( ) const

Definition at line 349 of file PosixProcess.cc.

◆ getIntervalAndValue()

void IntervalTimer::getIntervalAndValue ( Time::Timestamp &  interval,
Time::Timestamp &  value 
)

Definition at line 273 of file PosixProcess.cc.

◆ getValue()

Time::Timestamp IntervalTimer::getValue ( ) const

Definition at line 353 of file PosixProcess.cc.

◆ setArmedLocked()

void IntervalTimer::setArmedLocked ( bool  armed)
private

Definition at line 339 of file PosixProcess.cc.

◆ setInterval()

void IntervalTimer::setInterval ( Time::Timestamp  interval,
Time::Timestamp *  prevInterval = nullptr 
)

Set the interval for the timer, which is loaded once the timer expires. Set zero to make a non-reloading timer.

Definition at line 201 of file PosixProcess.cc.

References signal().

◆ setIntervalAndValue()

void IntervalTimer::setIntervalAndValue ( Time::Timestamp  interval,
Time::Timestamp  value,
Time::Timestamp *  prevInterval = nullptr,
Time::Timestamp *  prevValue = nullptr 
)

Set both interval and value atomically.

Definition at line 236 of file PosixProcess.cc.

References signal().

◆ setTimerValue()

void IntervalTimer::setTimerValue ( Time::Timestamp  value,
Time::Timestamp *  prevValue = nullptr 
)

Set the current value of the timer.

Definition at line 218 of file PosixProcess.cc.

References signal().

◆ signal()

void IntervalTimer::signal ( )
private
Todo:
sanity check that this is absolutely a PosixSubsystem

Definition at line 381 of file PosixProcess.cc.

References Process::acquireProcessSignalThread(), Hardware, Scheduler::instance(), Profile, PosixSubsystem::sendSignal(), signal(), and Virtual.

Referenced by consumeCpuTime(), setInterval(), setIntervalAndValue(), setTimerValue(), signal(), and timer().

+ Here is the caller graph for this function:

◆ timer()

void IntervalTimer::timer ( uint64_t  delta)
privatevirtual

Called when the handler is registered with the Timer class and a timer event occurred.

Parameters
[in]deltatime elapsed since the last event, in nanoseconds.

Implements TimerHandler.

Definition at line 357 of file PosixProcess.cc.

References Hardware, and signal().

Member Data Documentation

◆ m_Armed

bool IntervalTimer::m_Armed
private

Definition at line 111 of file PosixProcess.h.

◆ m_Interval

Time::Timestamp IntervalTimer::m_Interval
private

Definition at line 108 of file PosixProcess.h.

◆ m_LastTotal

Time::Timestamp IntervalTimer::m_LastTotal
private

Definition at line 109 of file PosixProcess.h.

◆ m_Lock

Spinlock IntervalTimer::m_Lock
private

Definition at line 110 of file PosixProcess.h.

◆ m_Mode

Mode IntervalTimer::m_Mode
private

Definition at line 106 of file PosixProcess.h.

◆ m_Process

PosixProcess* IntervalTimer::m_Process
private

Definition at line 105 of file PosixProcess.h.

◆ m_pTimer

Timer* IntervalTimer::m_pTimer
private

Definition at line 112 of file PosixProcess.h.

◆ m_Value

Time::Timestamp IntervalTimer::m_Value
private

Definition at line 107 of file PosixProcess.h.


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