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
I think you will find that the default scheduling policy for a new pthread is
PTHREAD_INHERIT_SCHED. To override this you need topthread_attr_init()an explicit set of attributes, futz about withpthread_attr_setschedpolicy()andpthread_attr_setschedparam(), and then apply those attributes inpthread_create().You could
sched_getscheduler()andsched_getparam()before setting the process toSCHED_DEADLINEand feed those into the pthread_attr for use later.