Use pthread_attr_setinheritsched(3C) to set the inherited scheduling policy.
int pthread_attr_setinheritsched(pthread_attr_t *tattr, int inheritsched);
#include <pthread.h> pthread_attr_t tattr; int inheritsched; int ret; /* use creating thread's scheduling policy and priority*/ ret = pthread_attr_setinheritsched(&tattr, PTHREAD_INHERIT_SCHED);
An inheritsched value of PTHREAD_INHERIT_SCHED means that the scheduling policy and priority of the creating thread are to be used for the created thread. The scheduling policy and priority in the attribute structure are to be ignored. An inheritsched value of PTHREAD_EXPLICIT_SCHED means that the scheduling policy and priority from the attribute structure are to be used for the created thread. The caller must have sufficient privilege for pthread_create() to succeed in this case.
pthread_attr_setinheritsched() returns zero after completing successfully. Any other return value indicates that an error occurred. When either of the following conditions occurs, the function fails and returns the corresponding value.
EINVAL
Description:An attempt was made to set tattr to a value that is not valid.