rt.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _SCHED_RT_H
  2. #define _SCHED_RT_H
  3. /*
  4. * Priority of a process goes from 0..MAX_PRIO-1, valid RT
  5. * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
  6. * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
  7. * values are inverted: lower p->prio value means higher priority.
  8. *
  9. * The MAX_USER_RT_PRIO value allows the actual maximum
  10. * RT priority to be separate from the value exported to
  11. * user-space. This allows kernel threads to set their
  12. * priority to a value higher than any user task. Note:
  13. * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
  14. */
  15. #define MAX_USER_RT_PRIO 100
  16. #define MAX_RT_PRIO MAX_USER_RT_PRIO
  17. #define MAX_PRIO (MAX_RT_PRIO + 40)
  18. #define DEFAULT_PRIO (MAX_RT_PRIO + 20)
  19. static inline int rt_prio(int prio)
  20. {
  21. if (unlikely(prio < MAX_RT_PRIO))
  22. return 1;
  23. return 0;
  24. }
  25. static inline int rt_task(struct task_struct *p)
  26. {
  27. return rt_prio(p->prio);
  28. }
  29. #ifdef CONFIG_RT_MUTEXES
  30. extern int rt_mutex_getprio(struct task_struct *p);
  31. extern void rt_mutex_setprio(struct task_struct *p, int prio);
  32. extern void rt_mutex_adjust_pi(struct task_struct *p);
  33. static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
  34. {
  35. return tsk->pi_blocked_on != NULL;
  36. }
  37. #else
  38. static inline int rt_mutex_getprio(struct task_struct *p)
  39. {
  40. return p->normal_prio;
  41. }
  42. # define rt_mutex_adjust_pi(p) do { } while (0)
  43. static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
  44. {
  45. return false;
  46. }
  47. #endif
  48. extern void normalize_rt_tasks(void);
  49. #endif /* _SCHED_RT_H */