gem5
|
Timer functions to interrupt VM execution after a number of simulation ticks. More...
#include <timer.hh>
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... | |
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.
|
inline |
|
pure virtual |
Arm the timer so that it fires after a certain number of ticks.
ticks | Number of ticks until the timer fires |
Implemented in PerfKvmTimer, and PosixKvmTimer.
|
protectedpure virtual |
Calculate the timer resolution, used by resolution() which caches the result.
Implemented in PerfKvmTimer, and PosixKvmTimer.
Referenced by resolution().
|
pure virtual |
Disarm the timer.
When this method has returned, the timer may no longer deliver signals upon timeout.
Implemented in PerfKvmTimer, and PosixKvmTimer.
|
inlineprotected |
Convert a time in simulator ticks to host cycles.
Definition at line 158 of file timer.hh.
References hostFactor, and hostFreq.
Referenced by PerfKvmTimer::arm().
|
inlineprotected |
Convert a time in simulator ticks to host nanoseconds.
Definition at line 148 of file timer.hh.
References hostFactor, and SimClock::Float::ns.
Referenced by PosixKvmTimer::arm().
|
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.
Definition at line 106 of file timer.hh.
References _resolution, and calcResolution().
Referenced by PosixKvmTimer::calcResolution().
|
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.
Definition at line 119 of file timer.hh.
References hostFactor, and hostFreq.
Referenced by PosixKvmTimer::calcResolution(), and PerfKvmTimer::calcResolution().
|
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.
Definition at line 130 of file timer.hh.
References hostFactor, and SimClock::Float::ns.
Referenced by PosixKvmTimer::calcResolution().
|
mutableprivate |
|
private |
Performance scaling factor.
Definition at line 170 of file timer.hh.
Referenced by hostCycles(), hostNs(), ticksFromHostCycles(), and ticksFromHostNs().
|
private |
Host frequency.
Definition at line 172 of file timer.hh.
Referenced by hostCycles(), and ticksFromHostCycles().
|
protected |
Signal to deliver when the timer times out.
Definition at line 163 of file timer.hh.
Referenced by PosixKvmTimer::PosixKvmTimer().