1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_SCHED_RT_H
3 #define _LINUX_SCHED_RT_H
5 #include <linux/sched.h>
9 static inline bool rt_prio(int prio)
11 return unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO);
14 static inline bool rt_or_dl_prio(int prio)
16 return unlikely(prio < MAX_RT_PRIO);
20 * Returns true if a task has a priority that belongs to RT class. PI-boosted
21 * tasks will return true. Use rt_policy() to ignore PI-boosted tasks.
23 static inline bool rt_task(struct task_struct *p)
25 return rt_prio(p->prio);
29 * Returns true if a task has a priority that belongs to RT or DL classes.
30 * PI-boosted tasks will return true. Use rt_or_dl_task_policy() to ignore
33 static inline bool rt_or_dl_task(struct task_struct *p)
35 return rt_or_dl_prio(p->prio);
39 * Returns true if a task has a policy that belongs to RT or DL classes.
40 * PI-boosted tasks will return false.
42 static inline bool rt_or_dl_task_policy(struct task_struct *tsk)
44 int policy = tsk->policy;
46 if (policy == SCHED_FIFO || policy == SCHED_RR)
48 if (policy == SCHED_DEADLINE)
53 #ifdef CONFIG_RT_MUTEXES
54 extern void rt_mutex_pre_schedule(void);
55 extern void rt_mutex_schedule(void);
56 extern void rt_mutex_post_schedule(void);
59 * Must hold either p->pi_lock or task_rq(p)->lock.
61 static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p)
63 return p->pi_top_task;
65 extern void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task);
66 extern void rt_mutex_adjust_pi(struct task_struct *p);
68 static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
72 # define rt_mutex_adjust_pi(p) do { } while (0)
75 extern void normalize_rt_tasks(void);
79 * default timeslice is 100 msecs (used only for SCHED_RR tasks).
80 * Timeslices get refilled after they expire.
82 #define RR_TIMESLICE (100 * HZ / 1000)
84 #endif /* _LINUX_SCHED_RT_H */