rt.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SCHED_RT_H
  3. #define _LINUX_SCHED_RT_H
  4. #include <linux/sched.h>
  5. struct task_struct;
  6. static inline int rt_prio(int prio)
  7. {
  8. if (unlikely(prio < MAX_RT_PRIO))
  9. return 1;
  10. return 0;
  11. }
  12. static inline int rt_task(struct task_struct *p)
  13. {
  14. return rt_prio(p->prio);
  15. }
  16. static inline bool task_is_realtime(struct task_struct *tsk)
  17. {
  18. int policy = tsk->policy;
  19. if (policy == SCHED_FIFO || policy == SCHED_RR)
  20. return true;
  21. if (policy == SCHED_DEADLINE)
  22. return true;
  23. return false;
  24. }
  25. #ifdef CONFIG_RT_MUTEXES
  26. /*
  27. * Must hold either p->pi_lock or task_rq(p)->lock.
  28. */
  29. static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p)
  30. {
  31. return p->pi_top_task;
  32. }
  33. extern void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task);
  34. extern void rt_mutex_adjust_pi(struct task_struct *p);
  35. #else
  36. static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
  37. {
  38. return NULL;
  39. }
  40. # define rt_mutex_adjust_pi(p) do { } while (0)
  41. #endif
  42. extern void normalize_rt_tasks(void);
  43. /*
  44. * default timeslice is 100 msecs (used only for SCHED_RR tasks).
  45. * Timeslices get refilled after they expire.
  46. */
  47. #define RR_TIMESLICE (100 * HZ / 1000)
  48. #endif /* _LINUX_SCHED_RT_H */