简体   繁体   中英

Detect deadline thread preemption

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM