masters-thesis/listings/rdtscp_wait.c

15 lines
214 B
C

uint64_t task_wait(struct task *t)
{
int ret;
uint64_t steps, now;
do {
now = rdtscp();
} while (now < t->next);
for (steps = 0; t->next < now; steps++)
t->next += t->period;
return steps;
}