I would like to let a process be scheduled under the new Linux SCHED_DEADLINE scheduling policy. Meanwhile, this process has to create some worker threads do to some other work. However, when I called pthread_create after a successful call of sched_setattr(which is to set the process scheduling policy), I got an EAGAIN. I know it might be a little strange to create a thread in a realtime process. Some problems such as "what scheduling policy of the new thread will be" may arise.
Despite of that , is there a way to create a new thread in a SCHED_DEADLINE process?
And how to define the scheduling policy of the new thread?
The code to reproduce my problem can be found at
When merging SCHED_DEADLINE, the kernel community explicitly discussed this topic in the list, and decided to not allow SCHED_DEADLINE tasks create other tasks (either by
fork()
or bypthread_create()
).Therefore, currently, there is no way of achieving such behavior. You have to create the tasks before setting the SCHED_DEADLINE priority.
Concerning the second question, unfortunately the glibc has not yet wrapped the sched_setattr() syscall (despite available since 4 years). Here is some code for creating a SCHED_DEADLINE task:
Then, in the task code: