1 /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
24 /* Get type definitions. */
25 #include <bits/types.h>
31 #include <bits/types/time_t.h>
32 #include <bits/types/struct_timespec.h>
37 #ifndef __pid_t_defined
38 typedef __pid_t pid_t
;
39 # define __pid_t_defined
43 /* Get system specific constant and data structure definitions. */
44 #include <bits/sched.h>
45 /* Define the real names for the elements of `struct sched_param'. */
46 #define sched_priority __sched_priority
51 /* Set scheduling parameters for a process. */
52 extern int sched_setparam (__pid_t __pid
, const struct sched_param
*__param
)
55 /* Retrieve scheduling parameters for a particular process. */
56 extern int sched_getparam (__pid_t __pid
, struct sched_param
*__param
) __THROW
;
58 /* Set scheduling algorithm and/or parameters for a process. */
59 extern int sched_setscheduler (__pid_t __pid
, int __policy
,
60 const struct sched_param
*__param
) __THROW
;
62 /* Retrieve scheduling algorithm for a particular purpose. */
63 extern int sched_getscheduler (__pid_t __pid
) __THROW
;
65 /* Yield the processor. */
66 extern int sched_yield (void) __THROW
;
68 /* Get maximum priority value for a scheduler. */
69 extern int sched_get_priority_max (int __algorithm
) __THROW
;
71 /* Get minimum priority value for a scheduler. */
72 extern int sched_get_priority_min (int __algorithm
) __THROW
;
74 /* Get the SCHED_RR interval for the named process. */
75 extern int sched_rr_get_interval (__pid_t __pid
, struct timespec
*__t
) __THROW
;
79 /* Access macros for `cpu_set'. */
80 # define CPU_SETSIZE __CPU_SETSIZE
81 # define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
82 # define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
83 # define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
85 # define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
86 # define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
88 # define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
89 # define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
90 # define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
92 # define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
93 # define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
95 # define CPU_EQUAL(cpusetp1, cpusetp2) \
96 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
97 # define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
98 __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
100 # define CPU_AND(destset, srcset1, srcset2) \
101 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
102 # define CPU_OR(destset, srcset1, srcset2) \
103 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
104 # define CPU_XOR(destset, srcset1, srcset2) \
105 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
106 # define CPU_AND_S(setsize, destset, srcset1, srcset2) \
107 __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
108 # define CPU_OR_S(setsize, destset, srcset1, srcset2) \
109 __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
110 # define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
111 __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
113 # define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
114 # define CPU_ALLOC(count) __CPU_ALLOC (count)
115 # define CPU_FREE(cpuset) __CPU_FREE (cpuset)
118 /* Set the CPU affinity for a task */
119 extern int sched_setaffinity (__pid_t __pid
, size_t __cpusetsize
,
120 const cpu_set_t
*__cpuset
) __THROW
;
122 /* Get the CPU affinity for a task */
123 extern int sched_getaffinity (__pid_t __pid
, size_t __cpusetsize
,
124 cpu_set_t
*__cpuset
) __THROW
;