I'm implementing a thread using SCHED_DEADLINE
scheduling policy which is my high-priority thread and another one using SCHED_FIFO
policy which is my low-priority one.
As an example, I've defined my deadline thread as follow :
attr.sched_runtime = 0.5 * 1000000; // --> 0.5 ms
attr.sched_deadline = 0.6 * 1000000; // --> 0.6 ms
attr.sched_period = 1 * 1000000; // --> 1 ms
In a normal behavior, my high-priority thread shouldn't process more than 0.5 ms and while this duration it should have the time to finish its task.
If the task last longer than 0.5 ms, OS scheduler will preempt my high-priority thread to give time to my low-priority. This is a behavior I've tested before.
My question is : how can my high priority thread be warned that it has been preempted by the system?
Currently, the SCHED_DEADLINE API doesn't provide the feature needed for signaling the task that it has been throttled. We understand that it could be a useful feature, and we will consider it for inclusion in the very next future.
The only option at the moment is to check the time for understanding if a throttling occurred.
Update: the Linux kernel 4.16 will add support for the "runtime overrun" signaling on SCHED_DEADLINE. See here.