Example #1
0
int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex,
		 RTIME timeout)
{
	struct service svc;
	ticks_t now;

	if (timeout != TM_INFINITE && timeout != TM_NONBLOCK) {
		COPPERPLATE_PROTECT(svc);
		clockobj_get_time(&alchemy_clock, &now, NULL);
		COPPERPLATE_UNPROTECT(svc);
		timeout += now;
	}

	return rt_cond_wait_until(cond, mutex, timeout);
}
Example #2
0
void clockobj_get_distance(struct clockobj *clkobj,
			   const struct itimerspec *itm,
			   struct timespec *delta)
{
	ticks_t now, start, interval, dist;

	clockobj_get_time(clkobj, &now, NULL);
	start = timespec_scalar(&itm->it_value);

	if (start >= now)
		/* Distance to first shot. */
		dist = start - now;
	else {
		interval = timespec_scalar(&itm->it_interval);
		/* Distance to next shot. */
		dist = interval - ((now - start) % interval);
	}

	__clockobj_ticks_to_timespec(clkobj, dist, delta);
}