gem5  v21.1.0.2
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
gem5::PosixKvmTimer Class Reference

Timer based on standard POSIX timers. More...

#include <timer.hh>

Inheritance diagram for gem5::PosixKvmTimer:
gem5::BaseKvmTimer

Public Member Functions

 PosixKvmTimer (int signo, clockid_t clockID, float hostFactor, Tick hostFreq)
 
 ~PosixKvmTimer ()
 
void arm (Tick ticks) override
 Arm the timer so that it fires after a certain number of ticks. More...
 
void disarm () override
 Disarm the timer. More...
 
bool expired () override
 
- Public Member Functions inherited from gem5::BaseKvmTimer
 BaseKvmTimer (int signo, float hostFactor, Tick hostFreq)
 Setup basic timer functionality shared by all timer implementations. More...
 
virtual ~BaseKvmTimer ()
 
Tick resolution ()
 Determine the resolution of the timer in ticks. More...
 
Tick ticksFromHostCycles (uint64_t cycles)
 Convert cycles executed on the host into Ticks executed in the simulator. More...
 
Tick ticksFromHostNs (uint64_t ns)
 Convert nanoseconds executed on the host into Ticks executed in the simulator. More...
 

Protected Member Functions

Tick calcResolution () override
 Calculate the timer resolution, used by resolution() which caches the result. More...
 
- Protected Member Functions inherited from gem5::BaseKvmTimer
uint64_t hostNs (Tick ticks)
 Convert a time in simulator ticks to host nanoseconds. More...
 
uint64_t hostCycles (Tick ticks)
 Convert a time in simulator ticks to host cycles. More...
 

Private Attributes

clockid_t clockID
 
timer_t timer
 
struct itimerspec prevTimerSpec
 

Additional Inherited Members

- Protected Attributes inherited from gem5::BaseKvmTimer
int signo
 Signal to deliver when the timer times out. More...
 

Detailed Description

Timer based on standard POSIX timers.

The POSIX timer API supports several different clock with different characteristics.

Note
It might be tempting to use CLOCK_(THREAD|PROCESS)_CPUTIME_ID, however, this clock usually has much lower resolution than the real-time clocks.

Definition at line 187 of file timer.hh.

Constructor & Destructor Documentation

◆ PosixKvmTimer()

gem5::PosixKvmTimer::PosixKvmTimer ( int  signo,
clockid_t  clockID,
float  hostFactor,
Tick  hostFreq 
)
Parameters
signoSignal to deliver
clockIDID of the clock to use
hostFactorPerformance scaling factor
hostFreqClock frequency of the host

Definition at line 79 of file timer.cc.

References clockID, panic, gem5::BaseKvmTimer::signo, gem5::sysGettid(), and timer.

◆ ~PosixKvmTimer()

gem5::PosixKvmTimer::~PosixKvmTimer ( )

Definition at line 97 of file timer.cc.

References timer.

Member Function Documentation

◆ arm()

void gem5::PosixKvmTimer::arm ( Tick  ticks)
overridevirtual

Arm the timer so that it fires after a certain number of ticks.

Note
A timer implementation is free to convert between simulation ticks and virtualized time using any method it chooses. The accuracy of the timer therefore depends on what it measures, an accurate timer implementation should measure the number of cycles or instructions executed in the guest. If such counters are unavailable, it may fallback to wall clock time.
Parameters
ticksNumber of ticks until the timer fires

Implements gem5::BaseKvmTimer.

Definition at line 103 of file timer.cc.

References DPRINTF, gem5::BaseKvmTimer::hostNs(), panic, timer, and gem5::ArmISA::ts.

◆ calcResolution()

Tick gem5::PosixKvmTimer::calcResolution ( )
overrideprotectedvirtual

Calculate the timer resolution, used by resolution() which caches the result.

Returns
Minimum number of ticks the timer can resolve

Implements gem5::BaseKvmTimer.

Definition at line 144 of file timer.cc.

References clockID, gem5::MIN_HOST_CYCLES, panic, gem5::BaseKvmTimer::resolution(), gem5::BaseKvmTimer::ticksFromHostCycles(), gem5::BaseKvmTimer::ticksFromHostNs(), and gem5::ArmISA::ts.

◆ disarm()

void gem5::PosixKvmTimer::disarm ( )
overridevirtual

Disarm the timer.

When this method has returned, the timer may no longer deliver signals upon timeout.

Implements gem5::BaseKvmTimer.

Definition at line 123 of file timer.cc.

References DPRINTF, panic, prevTimerSpec, timer, and gem5::ArmISA::ts.

◆ expired()

bool gem5::PosixKvmTimer::expired ( )
overridevirtual

Reimplemented from gem5::BaseKvmTimer.

Definition at line 137 of file timer.cc.

References prevTimerSpec.

Member Data Documentation

◆ clockID

clockid_t gem5::PosixKvmTimer::clockID
private

Definition at line 208 of file timer.hh.

Referenced by calcResolution(), and PosixKvmTimer().

◆ prevTimerSpec

struct itimerspec gem5::PosixKvmTimer::prevTimerSpec
private

Definition at line 210 of file timer.hh.

Referenced by disarm(), and expired().

◆ timer

timer_t gem5::PosixKvmTimer::timer
private

Definition at line 209 of file timer.hh.

Referenced by arm(), disarm(), PosixKvmTimer(), and ~PosixKvmTimer().


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

Generated on Tue Sep 21 2021 12:27:58 for gem5 by doxygen 1.8.17