sched_stoptask.c 2.2 KB

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