Go to the documentation of this file.
40 #include <sys/syscall.h>
49 #include "debug/KvmTimer.hh"
57 #ifndef sigev_notify_thread_id
58 #define sigev_notify_thread_id _sigev_un._tid
64 return syscall(__NR_gettid);
77 float hostFactor,
Tick hostFreq)
83 sev.sigev_notify = SIGEV_THREAD_ID;
84 sev.sigev_signo =
signo;
86 sev.sigev_value.sival_ptr = NULL;
90 panic(
"timer_create: %i", errno);
102 struct itimerspec
ts;
103 memset(&
ts, 0,
sizeof(
ts));
105 ts.it_interval.tv_sec = 0;
106 ts.it_interval.tv_nsec = 0;
107 ts.it_value.tv_sec =
hostNs(ticks) / 1000000000
ULL;
108 ts.it_value.tv_nsec =
hostNs(ticks) % 1000000000
ULL;
110 assert(
ts.it_value.tv_nsec > 0 ||
ts.it_value.tv_sec > 0);
112 DPRINTF(KvmTimer,
"Arming POSIX timer: %i ticks (%is%ins)\n",
113 ticks,
ts.it_value.tv_sec,
ts.it_value.tv_nsec);
115 if (timer_settime(
timer, 0, &
ts, NULL) == -1)
116 panic(
"PosixKvmTimer: Failed to arm timer\n");
122 struct itimerspec
ts;
123 memset(&
ts, 0,
sizeof(
ts));
126 panic(
"PosixKvmTimer: Failed to disarm timer\n");
128 DPRINTF(KvmTimer,
"Disarmed POSIX timer: %is%ins left\n",
146 panic(
"PosixKvmTimer: Failed to get timer resolution\n");
148 const uint64_t res_ns(
ts.tv_sec * 1000000000
ULL +
ts.tv_nsec);
169 int signo,
float hostFactor,
Tick hostFreq)
void arm(Tick ticks)
Arm the timer so that it fires after a certain number of ticks.
An instance of a performance counter.
void disarm()
Disarm the timer.
Tick ticksFromHostNs(uint64_t ns)
Convert nanoseconds executed on the host into Ticks executed in the simulator.
Tick ticksFromHostCycles(uint64_t cycles)
Convert cycles executed on the host into Ticks executed in the simulator.
void arm(Tick ticks) override
Arm the timer so that it fires after a certain number of ticks.
uint64_t hostNs(Tick ticks)
Convert a time in simulator ticks to host nanoseconds.
PerfKvmTimer(PerfKvmCounter &ctr, int signo, float hostFactor, Tick hostFreq)
Create a timer that uses an existing hardware cycle counter.
uint64_t Tick
Tick count type.
struct itimerspec prevTimerSpec
void disarm() override
Disarm the timer.
Tick calcResolution()
Calculate the timer resolution, used by resolution() which caches the result.
void period(uint64_t period)
Update the period of an overflow counter.
void enableSignals(pid_t tid, int signal)
Enable signal delivery to a thread on counter overflow.
int signo
Signal to deliver when the timer times out.
PosixKvmTimer(int signo, clockid_t clockID, float hostFactor, Tick hostFreq)
static const uint64_t MIN_HOST_CYCLES
Minimum number of cycles that a host can spend in a KVM call (used to calculate the resolution of som...
Tick calcResolution() override
Calculate the timer resolution, used by resolution() which caches the result.
Timer functions to interrupt VM execution after a number of simulation ticks.
void stop()
Stop counting.
Tick resolution()
Determine the resolution of the timer in ticks.
PerfKvmCounter & hwOverflow
uint64_t hostCycles(Tick ticks)
Convert a time in simulator ticks to host cycles.
#define ULL(N)
uint64_t constant
#define panic(...)
This implements a cprintf based panic() function.
void refresh(int refresh)
Enable a counter for a fixed number of events.
Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17