Skip to content

Commit 29ea9f0

Browse files
committed
process-util: add sched_{policy,priority}_is_valid()
1 parent 032cf8e commit 29ea9f0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/basic/process-util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
***/
2121

2222
#include <alloca.h>
23+
#include <sched.h>
2324
#include <signal.h>
2425
#include <stdbool.h>
2526
#include <stddef.h>
@@ -110,6 +111,14 @@ static inline bool nice_is_valid(int n) {
110111
return n >= PRIO_MIN && n < PRIO_MAX;
111112
}
112113

114+
static inline bool sched_policy_is_valid(int i) {
115+
return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
116+
}
117+
118+
static inline bool sched_priority_is_valid(int i) {
119+
return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
120+
}
121+
113122
static inline bool ioprio_class_is_valid(int i) {
114123
return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE);
115124
}

0 commit comments

Comments
 (0)