• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015 Cui Bixuan <cuibixuan@huawei.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 #ifndef __SCHED_H__
20 #define __SCHED_H__
21 
22 #include "lapi/syscalls.h"
23 #include <stdint.h>
24 #include <inttypes.h>
25 
26 struct sched_attr {
27 	uint32_t size;
28 
29 	uint32_t sched_policy;
30 	uint64_t sched_flags;
31 
32 	/* SCHED_NORMAL, SCHED_BATCH */
33 	int32_t sched_nice;
34 
35 	/* SCHED_FIFO, SCHED_RR */
36 	uint32_t sched_priority;
37 
38 	/* SCHED_DEADLINE (nsec) */
39 	uint64_t sched_runtime;
40 	uint64_t sched_deadline;
41 	uint64_t sched_period;
42 };
43 
sched_setattr(pid_t pid,const struct sched_attr * attr,unsigned int flags)44 int sched_setattr(pid_t pid,
45 	const struct sched_attr *attr,
46 	unsigned int flags)
47 {
48 	return syscall(__NR_sched_setattr, pid, attr, flags);
49 }
50 
sched_getattr(pid_t pid,struct sched_attr * attr,unsigned int size,unsigned int flags)51 int sched_getattr(pid_t pid,
52 	struct sched_attr *attr,
53 	unsigned int size,
54 	unsigned int flags)
55 {
56 	return syscall(__NR_sched_getattr, pid, attr, size, flags);
57 }
58 
59 #ifndef CLONE_VM
60 #define CLONE_VM   0x00000100
61 #endif
62 
63 #ifndef CLONE_FS
64 #define CLONE_FS   0x00000200
65 #endif
66 
67 #ifndef CLONE_SYSVSEM
68 #define CLONE_SYSVSEM   0x00040000
69 #endif
70 
71 #ifndef CLONE_IO
72 #define CLONE_IO        0x80000000
73 #endif
74 
75 #endif /* __SCHED_H__ */
76