gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
BaseKvmTimer Class Referenceabstract

Timer functions to interrupt VM execution after a number of simulation ticks. More...

#include <timer.hh>

Inheritance diagram for BaseKvmTimer:
PerfKvmTimer PosixKvmTimer

Public Member Functions

 BaseKvmTimer (int signo, float hostFactor, Tick hostFreq)
 Setup basic timer functionality shared by all timer implementations. More...
 
virtual ~BaseKvmTimer ()
 
virtual void arm (Tick ticks)=0
 Arm the timer so that it fires after a certain number of ticks. More...
 
virtual void disarm ()=0
 Disarm the timer. More...
 
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

virtual Tick calcResolution ()=0
 Calculate the timer resolution, used by resolution() which caches the result. More...
 
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...
 

Protected Attributes

int signo
 Signal to deliver when the timer times out. More...
 

Private Attributes

Tick _resolution
 Cached resolution. More...
 
float hostFactor
 Performance scaling factor. More...
 
Tick hostFreq
 Host frequency. More...
 

Detailed Description

Timer functions to interrupt VM execution after a number of simulation ticks.

The timer allows scaling of the host time to take performance differences between the simulated and real CPU into account.

The performance scaling factor is ratio between the target's CPI and the host's CPI. It is larger than 1 if the host is faster than the target and lower than 1 if it is slower.

When the timer times out, it sends a signal to the thread that started the timer. The signal forces KVM to drop out of the system call that started the guest and hands control to gem5.

Definition at line 62 of file timer.hh.

Constructor & Destructor Documentation

BaseKvmTimer::BaseKvmTimer ( int  signo,
float  hostFactor,
Tick  hostFreq 
)
inline

Setup basic timer functionality shared by all timer implementations.

Parameters
signoSignal to deliver
hostFactorPerformance scaling factor
hostFreqClock frequency of the host

Definition at line 73 of file timer.hh.

virtual BaseKvmTimer::~BaseKvmTimer ( )
inlinevirtual

Definition at line 76 of file timer.hh.

Member Function Documentation

virtual void BaseKvmTimer::arm ( Tick  ticks)
pure virtual

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

Implemented in PerfKvmTimer, and PosixKvmTimer.

virtual Tick BaseKvmTimer::calcResolution ( )
protectedpure virtual

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

Returns
Minimum number of ticks the timer can resolve

Implemented in PerfKvmTimer, and PosixKvmTimer.

Referenced by resolution().

virtual void BaseKvmTimer::disarm ( )
pure virtual

Disarm the timer.

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

Implemented in PerfKvmTimer, and PosixKvmTimer.

uint64_t BaseKvmTimer::hostCycles ( Tick  ticks)
inlineprotected

Convert a time in simulator ticks to host cycles.

Returns
Simulation ticks converted into CPU cycles on the host

Definition at line 158 of file timer.hh.

References hostFactor, and hostFreq.

Referenced by PerfKvmTimer::arm().

uint64_t BaseKvmTimer::hostNs ( Tick  ticks)
inlineprotected

Convert a time in simulator ticks to host nanoseconds.

Returns
Simulation ticks converted into nanoseconds on the host

Definition at line 148 of file timer.hh.

References hostFactor, and SimClock::Float::ns.

Referenced by PosixKvmTimer::arm().

Tick BaseKvmTimer::resolution ( )
inline

Determine the resolution of the timer in ticks.

This method is mainly used to determine the smallest number of ticks the timer can wait before triggering a signal.

Returns
Minimum number of ticks the timer can resolve

Definition at line 106 of file timer.hh.

References _resolution, and calcResolution().

Referenced by PosixKvmTimer::calcResolution().

Tick BaseKvmTimer::ticksFromHostCycles ( uint64_t  cycles)
inline

Convert cycles executed on the host into Ticks executed in the simulator.

Scales the results using the hostFactor to take CPU performance differences into account.

Returns
Host cycles executed in VM converted to simulation ticks

Definition at line 119 of file timer.hh.

References hostFactor, and hostFreq.

Referenced by PosixKvmTimer::calcResolution(), and PerfKvmTimer::calcResolution().

Tick BaseKvmTimer::ticksFromHostNs ( uint64_t  ns)
inline

Convert nanoseconds executed on the host into Ticks executed in the simulator.

Scales the results using the hostFactor to take CPU performance differences into account.

Returns
Nanoseconds executed in VM converted to simulation ticks

Definition at line 130 of file timer.hh.

References hostFactor, and SimClock::Float::ns.

Referenced by PosixKvmTimer::calcResolution().

Member Data Documentation

Tick BaseKvmTimer::_resolution
mutableprivate

Cached resolution.

Definition at line 167 of file timer.hh.

Referenced by resolution().

float BaseKvmTimer::hostFactor
private

Performance scaling factor.

Definition at line 170 of file timer.hh.

Referenced by hostCycles(), hostNs(), ticksFromHostCycles(), and ticksFromHostNs().

Tick BaseKvmTimer::hostFreq
private

Host frequency.

Definition at line 172 of file timer.hh.

Referenced by hostCycles(), and ticksFromHostCycles().

int BaseKvmTimer::signo
protected

Signal to deliver when the timer times out.

Definition at line 163 of file timer.hh.

Referenced by PosixKvmTimer::PosixKvmTimer().


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

Generated on Fri Jun 9 2017 13:04:03 for gem5 by doxygen 1.8.6