| 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * rt-sched.h - sched_setattr() and sched_getattr() API |
| 4 | * (C) Dario Faggioli <[email protected]>, 2009, 2010 |
| 5 | * Copyright (C) 2014 BMW Car IT GmbH, Daniel Wagner <[email protected] |
| 6 | */ |
| 7 | |
| 8 | /* This file is based on Dario Faggioli's libdl. Eventually it will be |
| 9 | replaced by a proper implemenation of this API. */ |
| 10 | |
| 11 | #ifndef __RT_SCHED_H__ |
| 12 | #define __RT_SCHED_H__ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | #include <sys/types.h> |
| 16 | |
| 17 | #ifndef SCHED_DEADLINE |
| 18 | #define SCHED_DEADLINE 6 |
| 19 | #endif |
| 20 | |
| 21 | #ifdef __x86_64__ |
| 22 | #define __NR_sched_setattr 314 |
| 23 | #define __NR_sched_getattr 315 |
| 24 | #endif |
| 25 | |
| 26 | #ifdef __i386__ |
| 27 | #define __NR_sched_setattr 351 |
| 28 | #define __NR_sched_getattr 352 |
| 29 | #endif |
| 30 | |
| 31 | #ifdef __arm__ |
| 32 | #ifndef __NR_sched_setattr |
| 33 | #define __NR_sched_setattr 380 |
| 34 | #endif |
| 35 | #ifndef __NR_sched_getattr |
| 36 | #define __NR_sched_getattr 381 |
| 37 | #endif |
| 38 | #endif |
| 39 | |
| 40 | #ifdef __tilegx__ |
| 41 | #define __NR_sched_setattr 274 |
| 42 | #define __NR_sched_getattr 275 |
| 43 | #endif |
| 44 | |
| 45 | /* sched_attr is not defined in glibc < 2.41 */ |
| 46 | #ifndef SCHED_ATTR_SIZE_VER0 |
| 47 | struct sched_attr { |
| 48 | uint32_t size; |
| 49 | uint32_t sched_policy; |
| 50 | uint64_t sched_flags; |
| 51 | |
| 52 | /* SCHED_NORMAL, SCHED_BATCH */ |
| 53 | int32_t sched_nice; |
| 54 | |
| 55 | /* SCHED_FIFO, SCHED_RR */ |
| 56 | uint32_t sched_priority; |
| 57 | |
| 58 | /* SCHED_DEADLINE */ |
| 59 | unsigned long long sched_runtime; |
| 60 | unsigned long long sched_deadline; |
| 61 | unsigned long long sched_period; |
| 62 | }; |
| 63 | |
| 64 | int sched_setattr(pid_t pid, |
| 65 | const struct sched_attr *attr, |
| 66 | unsigned int flags); |
| 67 | |
| 68 | int sched_getattr(pid_t pid, |
| 69 | struct sched_attr *attr, |
| 70 | unsigned int size, |
| 71 | unsigned int flags); |
| 72 | |
| 73 | #endif /* SCHED_ATTR_SIZE_VER0 */ |
| 74 | |
| 75 | #endif /* __RT_SCHED_H__ */ |