1
/*
2
 this sticks around for documentation issues only and will be removed in the next
3
 release - it documents the direct syscalls for affinity, without going thru glibc
4
 */
5
6
#if 0
7
8
/* 
9
 I don't know where this was exactly taken from, but I think I found it
10
 in glibc.
11
 */
12
#include <linux/unistd.h>
13
#define __NR_sched_setaffinity	241
14
#define __NR_sched_getaffinity	242
15
16
/*
17
 a nice macro to define the following:
18
 it's a syscall with 3 args,
19
 it returns int,
20
 it's named sched_....,
21
 the next arg is of type pid_t,
22
 has the local name pid,
23
 next is unsigned int,
24
 with name len,
25
 then an unsigned long *,
26
 named user_mask_ptr
27
 */
28
_syscall3 (int, sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr)
29
_syscall3 (int, sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr)
30
31
#endif
32
33
#include <linux/kernel.h>
34
#include <linux/unistd.h>
35
#include <linux/types.h>
36
#include <time.h>
37
38
/* XXX use the proper syscall numbers */
39
#ifdef __x86_64__
40
#define __NR_sched_setscheduler_ex	303
41
#define __NR_sched_getparam_ex		305
42
#endif
43
44
#ifdef __i386__
45
#define __NR_sched_setscheduler_ex	341
46
#define __NR_sched_getparam_ex		343
47
#endif
48
49
#ifdef __arm__
50
#define __NR_sched_setscheduler_ex	370
51
#define __NR_sched_getparam_ex		372
52
#endif
53
54
#define SF_SIG_RORUN	2
55
#define SF_SIG_DMISS	4
56
57
struct sched_param_ex {
58
	int sched_priority;
59
	struct timespec sched_runtime;
60
	struct timespec sched_deadline;
61
	struct timespec sched_period;
62
	unsigned int sched_flags;
63
	struct timespec curr_runtime;
64
	struct timespec used_runtime;
65
	struct timespec curr_deadline;
66
};
67
68
#define sched_setscheduler_ex(pid, policy, len, param) \
69
	syscall(__NR_sched_setscheduler_ex, pid, policy, len, param)
70
71
#define sched_getparam_ex(pid, len, param) \
72
	syscall(__NR_sched_getparam_ex, pid, len, param)