sched_stoptask.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * stop-task scheduling class.
  3. *
  4. * The stop task is the highest priority task in the system, it preempts
  5. * everything and will be preempted by nothing.
  6. *
  7. * See kernel/stop_machine.c
  8. */
  9. #ifdef CONFIG_SMP
  10. static int
  11. select_task_rq_stop(struct task_struct *p, int sd_flag, int flags)
  12. {
  13. return task_cpu(p); /* stop tasks as never migrate */
  14. }
  15. #endif /* CONFIG_SMP */
  16. static void
  17. check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags)
  18. {
  19. /* we're never preempted */
  20. }
  21. static struct task_struct *pick_next_task_stop(struct rq *rq)
  22. {
  23. struct task_struct *stop = rq->stop;
  24. if (stop && stop->on_rq)
  25. return stop;
  26. return NULL;
  27. }
  28. static void
  29. enqueue_task_stop(struct rq *rq, struct task_struct *p, int flags)
  30. {
  31. }
  32. static void
  33. dequeue_task_stop(struct rq *rq, struct task_struct *p, int flags)
  34. {
  35. }
  36. static void yield_task_stop(struct rq *rq)
  37. {
  38. BUG(); /* the stop task should never yield, its pointless. */
  39. }
  40. static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
  41. {
  42. }
  43. static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
  44. {
  45. }
  46. static void set_curr_task_stop(struct rq *rq)
  47. {
  48. }
  49. static void switched_to_stop(struct rq *rq, struct task_struct *p)
  50. {
  51. BUG(); /* its impossible to change to this class */
  52. }
  53. static void
  54. prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio)
  55. {
  56. BUG(); /* how!?, what priority? */
  57. }
  58. static unsigned int
  59. get_rr_interval_stop(struct rq *rq, struct task_struct *task)
  60. {
  61. return 0;
  62. }
  63. /*
  64. * Simple, special scheduling class for the per-CPU stop tasks:
  65. */
  66. static const struct sched_class stop_sched_class = {
  67. .next = &rt_sched_class,
  68. .enqueue_task = enqueue_task_stop,
  69. .dequeue_task = dequeue_task_stop,
  70. .yield_task = yield_task_stop,
  71. .check_preempt_curr = check_preempt_curr_stop,
  72. .pick_next_task = pick_next_task_stop,
  73. .put_prev_task = put_prev_task_stop,
  74. #ifdef CONFIG_SMP
  75. .select_task_rq = select_task_rq_stop,
  76. #endif
  77. .set_curr_task = set_curr_task_stop,
  78. .task_tick = task_tick_stop,
  79. .get_rr_interval = get_rr_interval_stop,
  80. .prio_changed = prio_changed_stop,
  81. .switched_to = switched_to_stop,
  82. };