rt.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
  36. {
  37. return tsk->pi_blocked_on != NULL;
  38. }
  39. #else
  40. static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task)
  41. {
  42. return NULL;
  43. }
  44. # define rt_mutex_adjust_pi(p) do { } while (0)
  45. static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
  46. {
  47. return false;
  48. }
  49. #endif
  50. extern void normalize_rt_tasks(void);
  51. /*
  52. * default timeslice is 100 msecs (used only for SCHED_RR tasks).
  53. * Timeslices get refilled after they expire.
  54. */
  55. #define RR_TIMESLICE (100 * HZ / 1000)
  56. #endif /* _LINUX_SCHED_RT_H */