blob: e5af028c08b4945a2572e5f797ed33d46e4b0123 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Ingo Molnar9ccd27c2017-02-03 21:11:09 +01002#ifndef _LINUX_SCHED_RT_H
3#define _LINUX_SCHED_RT_H
Clark Williams8bd75c72013-02-07 09:47:07 -06004
Ingo Molnar9ccd27c2017-02-03 21:11:09 +01005#include <linux/sched.h>
6
7struct task_struct;
Clark Williams8bd75c72013-02-07 09:47:07 -06008
9static inline int rt_prio(int prio)
10{
11 if (unlikely(prio < MAX_RT_PRIO))
12 return 1;
13 return 0;
14}
15
16static inline int rt_task(struct task_struct *p)
17{
18 return rt_prio(p->prio);
19}
20
Sebastian Andrzej Siewiorff0d4a92017-10-04 17:49:00 +020021static inline bool task_is_realtime(struct task_struct *tsk)
22{
23 int policy = tsk->policy;
24
25 if (policy == SCHED_FIFO || policy == SCHED_RR)
26 return true;
27 if (policy == SCHED_DEADLINE)
28 return true;
29 return false;
30}
31
Clark Williams8bd75c72013-02-07 09:47:07 -060032#ifdef CONFIG_RT_MUTEXES
Peter Zijlstraacd58622017-03-23 15:56:11 +010033/*
34 * Must hold either p->pi_lock or task_rq(p)->lock.
35 */
36static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p)
37{
38 return p->pi_top_task;
39}
40extern void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task);
Clark Williams8bd75c72013-02-07 09:47:07 -060041extern void rt_mutex_adjust_pi(struct task_struct *p);
42static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
43{
44 return tsk->pi_blocked_on != NULL;
45}
46#else
Dario Faggioli2d3d8912013-11-07 14:43:44 +010047static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
48{
49 return NULL;
50}
Clark Williams8bd75c72013-02-07 09:47:07 -060051# define rt_mutex_adjust_pi(p) do { } while (0)
52static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
53{
54 return false;
55}
56#endif
57
58extern void normalize_rt_tasks(void);
59
60
Clark Williamsbc681592013-02-22 09:20:11 -080061/*
62 * default timeslice is 100 msecs (used only for SCHED_RR tasks).
63 * Timeslices get refilled after they expire.
64 */
65#define RR_TIMESLICE (100 * HZ / 1000)
66
Ingo Molnar9ccd27c2017-02-03 21:11:09 +010067#endif /* _LINUX_SCHED_RT_H */