-
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?
Conversation
Already present in all other OSes. Unfortunately, not great on gnulinux as the clock used for timing out is the realtime clock.
This allows to specify a timeout on aperiodic activities, which is how long the activity will wait for a trigger before being called anyways. This is meant to implement timeout mechanisms in case no trigger ever comes (e.g. on port-driven tasks)
This basically allows to run This all makes sense, even though the code base is confusingly using a variable named The Thanks to this, i learned that i was rather wrong about |
clock_gettime(CLOCK_REALTIME, &ts); | ||
long long delay_s = delay / 1000000000; | ||
|
||
ts.tv_nsec += delay - delay_s * 1000000000;; |
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.
ts.tv_nsec += delay - delay_s * 1000000000;; | |
ts.tv_nsec += delay - delay_s * 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I did not get this ts.tv_nsec -= sec * 1000000000;
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.
It is essentially ts.tv_nsec = ts.tv_nsec % 1000000000;
. I'm not sure why I wrote it this way except to be confusing.
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.
Sometimes, this is needed to keep values positive? Iirc, the / and % pair "rounds" towards 0.
On FileDescriptorActivity, it makes a common API for an API that already existed. For Activity when it is not periodic (i.e. port-driven), it allows to get a time-based wakeup. For the others, it keeps their properties, which is unthreaded for SequentialActivity and SlaveActivity (which means we can't wake them up), and purely periodic for PeriodicActivity and Activity with a period. |
A.k.a. "port driven with timeout"