48 #include "../oro_limits.h" 49 #include "../../rtt-config.h" 81 #define ORO_WAIT_ABS 0 83 #define ORO_WAIT_REL 1 99 #define ORO_SCHED_RT 0 100 #define ORO_SCHED_OTHER 1 102 //conflicts with another struct under MSVC 115 timevl.tv_sec = (long)(hrt / 1000000000LL);
116 timevl.tv_nsec = (long)(hrt % 1000000000LL);
124 QueryPerformanceFrequency(&freq);
125 QueryPerformanceCounter(&ticks);
127 return(
NANO_TIME)(((double)ticks.QuadPart * 1000000000LL) / (double)freq.QuadPart);
143 if (nano > 3000000L) Sleep((DWORD)(nano/1000000L) - 1);
177 *m = CreateSemaphore(NULL, value, 100000, NULL);
178 return (*m != NULL) ? 0 : -1;
189 return (ReleaseSemaphore(*m, 1, NULL) == 0) ? -1 : 0;
194 return (WaitForSingleObject(*m, INFINITE) == WAIT_FAILED) ? -1 : 0;
199 return (WaitForSingleObject(*m, 0) == WAIT_TIMEOUT) ? -1 : 0;
204 return (WaitForSingleObject(*m, (DWORD)(delay/1000000)) == WAIT_TIMEOUT) ? -1 : 0;
211 return rtos_sem_wait_timed(m, delay);
218 switch (WaitForSingleObject(*m, 0))
221 if (!ReleaseSemaphore(*m, 1, &previous))
return -1;
223 case WAIT_TIMEOUT:
return 0;
236 InitializeCriticalSection(m);
242 DeleteCriticalSection(m);
258 EnterCriticalSection(m);
264 LeaveCriticalSection(m);
270 if(TryEnterCriticalSection(m) != 0)
return 0;
313 enum { SIGNAL = 0, BROADCAST = 1, MAX_EVENTS = 2 };
315 HANDLE events_[MAX_EVENTS];
354 static inline int rtos_cond_timedwait_internal(
rt_cond_t *cond,
rt_mutex_t *external_mutex, DWORD ms)
364 LeaveCriticalSection (external_mutex);
369 int result = WaitForMultipleObjects (2, cond->
events_, FALSE, ms);
384 EnterCriticalSection (external_mutex);
391 return rtos_cond_timedwait_internal(cond, mutex, (DWORD)(abs_time / 1000000));
396 return rtos_cond_timedwait_internal(cond, mutex, INFINITE);
411 static inline int rtos_cond_signal (
rt_cond_t *cond)
423 #define rtos_printf printf 425 int setenv(
const char *name,
const char *value,
int overwrite);
int rtos_mutex_init(rt_mutex_t *m)
const double InfiniteSeconds
int rtos_mutex_rec_lock(rt_rec_mutex_t *m)
const TICK_TIME InfiniteTicks
int setenv(const char *name, const char *value, int overwrite)
int rtos_cond_destroy(rt_cond_t *cond)
NANO_TIME rtos_get_time_ns(void)
Get "system" time in nanoseconds.
int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
const NANO_TIME InfiniteNSecs
int rtos_mutex_rec_init(rt_rec_mutex_t *m)
int rtos_sem_trywait(rt_sem_t *m)
int rtos_mutex_rec_trylock(rt_rec_mutex_t *m)
int rtos_sem_signal(rt_sem_t *m)
unsigned int waiters_count_
int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time)
int win32_nanosleep(long long nano)
int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex)
TIME_SPEC ticks2timespec(TICK_TIME hrt)
cyg_tick_count_t TICK_TIME
int rtos_mutex_unlock(rt_mutex_t *m)
int rtos_mutex_rec_unlock(rt_rec_mutex_t *m)
HANDLE events_[MAX_EVENTS]
void rtos_disable_rt_warning()
Disallows the RTOS to print a warning when we violate real-time constraints.
int rtos_sem_destroy(rt_sem_t *m)
int rtos_mutex_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
RTT_API unsigned int sleep(unsigned int seconds)
int rtos_mutex_rec_lock_until(rt_rec_mutex_t *m, NANO_TIME abs_time)
int rtos_mutex_lock(rt_mutex_t *m)
TICK_TIME rtos_get_time_ticks(void)
Get "system" time in ticks FIXME see https://proj.fmtc.be/orocos-bugzilla/show_bug.cgi?id=60
RTT_API int usleep(unsigned int us)
int rtos_mutex_trylock(rt_mutex_t *m)
NANO_TIME ticks2nano(TICK_TIME count)
Time conversions from system ticks to nano seconds.
cyg_recursive_mutex_t rt_rec_mutex_t
int rtos_sem_init(rt_sem_t *m, int value)
All these should return zero in case of succes.
TICK_TIME nano2ticks(NANO_TIME nano)
Time conversions from nano seconds to system ticks.
int rtos_mutex_destroy(rt_mutex_t *m)
int rtos_sem_value(rt_sem_t *m)
CRITICAL_SECTION waiters_count_lock_
void rtos_enable_rt_warning()
Allows the RTOS to print a warning when we violate real-time constraints.
struct timespec TIME_SPEC
int rtos_cond_init(rt_cond_t *cond)
int rtos_sem_wait(rt_sem_t *m)
int rtos_cond_broadcast(rt_cond_t *cond)
int rtos_mutex_rec_destroy(rt_rec_mutex_t *m)