• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "pthread_impl.h"
2 #include "lock.h"
3 
pthread_getschedparam(pthread_t t,int * restrict policy,struct sched_param * restrict param)4 int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param)
5 {
6 	int r;
7 	sigset_t set;
8 	__block_app_sigs(&set);
9 	LOCK(t->killlock);
10 	if (!t->tid) {
11 		r = ESRCH;
12 	} else {
13 		r = __syscall(SYS_sched_getparam, t->tid, param, MUSL_TYPE_THREAD);
14 		if (r >= 0) {
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 	__restore_sigs(&set);
28 	return r;
29 }
30