Beispiel #1
0
struct timespec TimeBase::systemTimespec() const
{
#ifdef _SYSTEM_LXRT_33_
  if (os::isThisLxrtTask())
  {
    struct timespec time = timespec();
    struct timespec global_now;
    os::gettimeofday(&global_now);

    RTIME rtime_rtai_now = rt_get_time();
    RTIME rtime_global_now = timespec2count(&global_now);
    RTIME rtime_time = timespec2count(&time);

    count2timespec(rtime_time + rtime_rtai_now - rtime_global_now, &time);

    return time;
  }
  else
  {
#endif
    return timespec();
#ifdef _SYSTEM_LXRT_33_
  }
#endif
}
bool RWLockImplLxrt38::readLock(const icl_core::TimeStamp& timeout)
{
#ifdef STRICT_LXRT_CHECKS
  if (!icl_core::os::isThisLxrtTask())
  {
    PRINTF("RWLockImplLxrt38::readLock: Called from a Linux task!\n");
    return false;
  }
#endif
  struct timespec timeout_spec = timeout.systemTimespec();
  int ret = rt_rwl_rdlock_until(m_rwlock, timespec2count(&timeout_spec));
  return (ret == 0);
}
Beispiel #3
0
RTAI_SYSCALL_MODE void rt_ptimer_settime(timer_t timer, const struct itimerspec *value, unsigned long data, long flags)
{
	struct rt_tasklet_struct *tasklet;
	RTIME now;

	tasklet = posix_timer[timer].timer;
	rt_remove_timer(tasklet);
	now = rt_get_time();
	if (flags == TIMER_ABSTIME)	{
		if (timespec2count(&(value->it_value)) < now) {
			now -= timespec2count (&(value->it_value));
		}else {
			now = 0;
		}
	}
	if (timespec2count ( &(value->it_value)) > 0) {
		if (data) {
			rt_insert_timer(tasklet, 0, now + timespec2count ( &(value->it_value) ), timespec2count ( &(value->it_interval) ), NULL, data, -1);
		} else {
			rt_insert_timer(tasklet, 0, now + timespec2count ( &(value->it_value) ), timespec2count ( &(value->it_interval) ), tasklet->handler, tasklet->data, 0);
		}
	}
}