1 #include "usr_lib_define.h" 2 #include "pthread_impl.h" 3 #include "lock.h" 4 pthread_setschedparam(pthread_t t,int policy,const struct sched_param * param)5_LIBC_TEXT_SECTION int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param) 6 { 7 int r; 8 9 if (policy != SCHED_RR && policy != SCHED_FIFO) { 10 return EINVAL; 11 } 12 13 if (param->sched_priority < 0 || param->sched_priority > PTHREAD_PRIORITY_LOWEST) { 14 return EINVAL; 15 } 16 17 LOCK(t->killlock); 18 r = !t->tid ? ESRCH : -__syscall(SYS_sched_setscheduler, t->tid, policy, param->sched_priority, MUSL_TYPE_THREAD); 19 UNLOCK(t->killlock); 20 return r; 21 } 22