• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2015 Cui Bixuan <cuibixuan@huawei.com>
4  */
5 
6 #ifndef LAPI_SCHED_H__
7 #define LAPI_SCHED_H__
8 
9 #include "lapi/syscalls.h"
10 #include <stdint.h>
11 #include <inttypes.h>
12 
13 struct sched_attr {
14 	uint32_t size;
15 
16 	uint32_t sched_policy;
17 	uint64_t sched_flags;
18 
19 	/* SCHED_NORMAL, SCHED_BATCH */
20 	int32_t sched_nice;
21 
22 	/* SCHED_FIFO, SCHED_RR */
23 	uint32_t sched_priority;
24 
25 	/* SCHED_DEADLINE (nsec) */
26 	uint64_t sched_runtime;
27 	uint64_t sched_deadline;
28 	uint64_t sched_period;
29 };
30 
sched_setattr(pid_t pid,const struct sched_attr * attr,unsigned int flags)31 static inline int sched_setattr(pid_t pid, const struct sched_attr *attr,
32                                 unsigned int flags)
33 {
34 	return syscall(__NR_sched_setattr, pid, attr, flags);
35 }
36 
sched_getattr(pid_t pid,struct sched_attr * attr,unsigned int size,unsigned int flags)37 static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
38                                 unsigned int size, unsigned int flags)
39 {
40 	return syscall(__NR_sched_getattr, pid, attr, size, flags);
41 }
42 
43 #ifndef CLONE_VM
44 #define CLONE_VM   0x00000100
45 #endif
46 
47 #ifndef CLONE_FS
48 #define CLONE_FS   0x00000200
49 #endif
50 
51 #ifndef CLONE_SYSVSEM
52 #define CLONE_SYSVSEM   0x00040000
53 #endif
54 
55 #ifndef CLONE_IO
56 #define CLONE_IO        0x80000000
57 #endif
58 
59 #endif /* LAPI_SCHED_H__ */
60