-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement trigger timeout on aperiodic tasks #13
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,9 +82,9 @@ extern "C" | |
static const NANO_TIME InfiniteNSecs = LLONG_MAX; | ||
static const double InfiniteSeconds = DBL_MAX; | ||
|
||
#define ORO_WAIT_ABS 0 /** rtos_task_wait_period may wait less than the duration required to pad the period to | ||
#define ORO_WAIT_ABS 0 /** rtos_task_wait_period may wait less than the duration required to pad the period to | ||
catch-up with overrun timesteps (wait according to an absolute timeline) */ | ||
#define ORO_WAIT_REL 1 /** rtos_task_wait_period will always pad the current timestep to the desired period, | ||
#define ORO_WAIT_REL 1 /** rtos_task_wait_period will always pad the current timestep to the desired period, | ||
regardless of previous overruns (wait according to a relative timeline) */ | ||
|
||
typedef struct { | ||
|
@@ -185,6 +185,19 @@ extern "C" | |
return sem_wait(m); | ||
} | ||
|
||
static inline int rtos_sem_wait_timed(rt_sem_t* m, NANO_TIME delay ) | ||
{ | ||
struct timespec ts; | ||
clock_gettime(CLOCK_REALTIME, &ts); | ||
long long delay_s = delay / 1000000000; | ||
|
||
ts.tv_nsec += delay - delay_s * 1000000000;; | ||
long sec = ts.tv_nsec / 1000000000; | ||
ts.tv_sec += delay_s + sec; | ||
ts.tv_nsec -= sec * 1000000000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not get this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is essentially There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes, this is needed to keep values positive? Iirc, the / and % pair "rounds" towards 0. |
||
return sem_timedwait(m, &ts); | ||
} | ||
|
||
static inline int rtos_sem_trywait(rt_sem_t* m ) | ||
{ | ||
return sem_trywait(m); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.