• 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 __SCHED_H__
7 #define __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 int sched_setattr(pid_t pid,
32 	const struct sched_attr *attr,
33 	unsigned int flags)
34 {
35 	return syscall(__NR_sched_setattr, pid, attr, flags);
36 }
37 
sched_getattr(pid_t pid,struct sched_attr * attr,unsigned int size,unsigned int flags)38 int sched_getattr(pid_t pid,
39 	struct sched_attr *attr,
40 	unsigned int size,
41 	unsigned int flags)
42 {
43 	return syscall(__NR_sched_getattr, pid, attr, size, flags);
44 }
45 
46 #ifndef CLONE_VM
47 #define CLONE_VM   0x00000100
48 #endif
49 
50 #ifndef CLONE_FS
51 #define CLONE_FS   0x00000200
52 #endif
53 
54 #ifndef CLONE_SYSVSEM
55 #define CLONE_SYSVSEM   0x00040000
56 #endif
57 
58 #ifndef CLONE_IO
59 #define CLONE_IO        0x80000000
60 #endif
61 
62 #endif /* __SCHED_H__ */
63