]> git.ipfire.org Git - thirdparty/glibc.git/blame - posix/sched.h
build-many-glibcs.py: Add openrisc hard float glibc variant
[thirdparty/glibc.git] / posix / sched.h
CommitLineData
7b3547eb 1/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
dff8da6b 2 Copyright (C) 1996-2024 Free Software Foundation, Inc.
7e3be507
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
7e3be507
UD
9
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
41bdb6e2 13 Lesser General Public License for more details.
7e3be507 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
7b3547eb
RM
18
19#ifndef _SCHED_H
20#define _SCHED_H 1
21
22#include <features.h>
23
24/* Get type definitions. */
5107cf1d 25#include <bits/types.h>
b9b49b44 26
50e16f85 27#define __need_size_t
05b68e14 28#define __need_NULL
50e16f85
UD
29#include <stddef.h>
30
05b68e14
ZW
31#include <bits/types/time_t.h>
32#include <bits/types/struct_timespec.h>
33#ifndef __USE_XOPEN2K
34# include <time.h>
bc61d27c 35#endif
7b3547eb 36
25fdd5d1
UD
37#ifndef __pid_t_defined
38typedef __pid_t pid_t;
39# define __pid_t_defined
40#endif
41
7b3547eb 42/* Get system specific constant and data structure definitions. */
5107cf1d 43#include <bits/sched.h>
46ee3da5
ZW
44#include <bits/cpu-set.h>
45
46/* Backward compatibility. */
47#define sched_priority sched_priority
c15f10ee 48#define __sched_priority sched_priority
4a2c9975 49
7b3547eb
RM
50
51__BEGIN_DECLS
52
53/* Set scheduling parameters for a process. */
a784e502 54extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
c1422e5b 55 __THROW;
7b3547eb
RM
56
57/* Retrieve scheduling parameters for a particular process. */
c1422e5b 58extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
7b3547eb
RM
59
60/* Set scheduling algorithm and/or parameters for a process. */
c1422e5b 61extern int sched_setscheduler (__pid_t __pid, int __policy,
a784e502 62 const struct sched_param *__param) __THROW;
7b3547eb
RM
63
64/* Retrieve scheduling algorithm for a particular purpose. */
c1422e5b 65extern int sched_getscheduler (__pid_t __pid) __THROW;
7b3547eb
RM
66
67/* Yield the processor. */
c1422e5b 68extern int sched_yield (void) __THROW;
7b3547eb
RM
69
70/* Get maximum priority value for a scheduler. */
c1422e5b 71extern int sched_get_priority_max (int __algorithm) __THROW;
7b3547eb
RM
72
73/* Get minimum priority value for a scheduler. */
c1422e5b 74extern int sched_get_priority_min (int __algorithm) __THROW;
7b3547eb
RM
75
76/* Get the SCHED_RR interval for the named process. */
a4ed0471 77#ifndef __USE_TIME64_REDIRECTS
c1422e5b 78extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
47f24c21
AZ
79#else
80# ifdef __REDIRECT_NTH
81extern int __REDIRECT_NTH (sched_rr_get_interval,
82 (__pid_t __pid, struct timespec *__t),
83 __sched_rr_get_interval64);
84# else
85# define sched_rr_get_interval __sched_rr_get_interval64
86# endif
87#endif
972e719e
UD
88
89#ifdef __USE_GNU
949ec764 90/* Access macros for `cpu_set'. */
b4afdd06 91# define CPU_SETSIZE __CPU_SETSIZE
a14ad5ae
UD
92# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
93# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
94# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
95 cpusetp)
96# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
97# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
98
99# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
100# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
101# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
102 cpusetp)
103# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
104# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
105
106# define CPU_EQUAL(cpusetp1, cpusetp2) \
107 __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
108# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
109 __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
110
111# define CPU_AND(destset, srcset1, srcset2) \
112 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
113# define CPU_OR(destset, srcset1, srcset2) \
114 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
115# define CPU_XOR(destset, srcset1, srcset2) \
116 __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
117# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
118 __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
119# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
120 __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
121# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
122 __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
123
124# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
125# define CPU_ALLOC(count) __CPU_ALLOC (count)
c4adefbd 126# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
949ec764
UD
127
128
972e719e 129/* Set the CPU affinity for a task */
439ff07b 130extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
a784e502 131 const cpu_set_t *__cpuset) __THROW;
972e719e
UD
132
133/* Get the CPU affinity for a task */
439ff07b
UD
134extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
135 cpu_set_t *__cpuset) __THROW;
972e719e
UD
136#endif
137
7b3547eb
RM
138__END_DECLS
139
140#endif /* sched.h */