gem5 v24.0.0.0
|
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. | |
virtual | ~BaseKvmTimer () |
virtual void | arm (Tick ticks)=0 |
Arm the timer so that it fires after a certain number of ticks. | |
virtual void | disarm ()=0 |
Disarm the timer. | |
virtual bool | expired () |
Tick | resolution () |
Determine the resolution of the timer in ticks. | |
Tick | ticksFromHostCycles (uint64_t cycles) |
Convert cycles executed on the host into Ticks executed in the simulator. | |
Tick | ticksFromHostNs (uint64_t ns) |
Convert nanoseconds executed on the host into Ticks executed in the simulator. | |
Protected Member Functions | |
virtual Tick | calcResolution ()=0 |
Calculate the timer resolution, used by resolution() which caches the result. | |
uint64_t | hostNs (Tick ticks) |
Convert a time in simulator ticks to host nanoseconds. | |
uint64_t | hostCycles (Tick ticks) |
Convert a time in simulator ticks to host cycles. | |
Protected Attributes | |
int | signo |
Signal to deliver when the timer times out. | |
Private Attributes | |
Tick | _resolution |
Cached resolution. | |
float | hostFactor |
Performance scaling factor. | |
Tick | hostFreq |
Host frequency. | |
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 gem5::PerfKvmTimer, and gem5::PosixKvmTimer.
|
protectedpure virtual |
Calculate the timer resolution, used by resolution() which caches the result.
Implemented in gem5::PerfKvmTimer, and gem5::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 gem5::PerfKvmTimer, and gem5::PosixKvmTimer.
|
inlinevirtual |
Reimplemented in gem5::PosixKvmTimer.
|
inlineprotected |
Convert a time in simulator ticks to host cycles.
Definition at line 162 of file timer.hh.
References hostFactor, and hostFreq.
Referenced by gem5::PerfKvmTimer::arm().
|
inlineprotected |
Convert a time in simulator ticks to host nanoseconds.
Definition at line 152 of file timer.hh.
References hostFactor, and gem5::sim_clock::as_float::ns.
Referenced by gem5::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 110 of file timer.hh.
References _resolution, and calcResolution().
Referenced by gem5::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 123 of file timer.hh.
References hostFactor, and hostFreq.
Referenced by gem5::PerfKvmTimer::calcResolution(), and gem5::PosixKvmTimer::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 134 of file timer.hh.
References hostFactor, gem5::ArmISA::ns, and gem5::sim_clock::as_float::ns.
Referenced by gem5::PosixKvmTimer::calcResolution().
|
mutableprivate |
|
private |
Performance scaling factor.
Definition at line 174 of file timer.hh.
Referenced by hostCycles(), hostNs(), ticksFromHostCycles(), and ticksFromHostNs().
|
private |
Host frequency.
Definition at line 176 of file timer.hh.
Referenced by hostCycles(), and ticksFromHostCycles().
|
protected |
Signal to deliver when the timer times out.
Definition at line 167 of file timer.hh.
Referenced by gem5::PerfKvmTimer::PerfKvmTimer(), and gem5::PosixKvmTimer::PosixKvmTimer().