• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "usr_lib_define.h"
2 #include "pthread_impl.h"
3 #include "lock.h"
4 
pthread_getschedparam(pthread_t t,int * restrict policy,struct sched_param * restrict param)5 _LIBC_TEXT_SECTION int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param)
6 {
7 	int r;
8 	LOCK(t->killlock);
9 	if (!t->tid) {
10 		r = ESRCH;
11 	} else {
12 		r = __syscall(SYS_sched_getparam, t->tid, MUSL_TYPE_THREAD);
13 		if (r >= 0) {
14 			param->sched_priority = r;
15 			r = __syscall(SYS_sched_getscheduler, t->tid, MUSL_TYPE_THREAD);
16 			if (r >= 0) {
17 				*policy = r;
18 				r = 0;
19 			}
20 		}
21 
22 		if (r < 0) {
23 			r = -r;
24 		}
25 	}
26 	UNLOCK(t->killlock);
27 	return r;
28 }
29