sched_idletask.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * idle-task scheduling class.
  3. *
  4. * (NOTE: these are not related to SCHED_IDLE tasks which are
  5. * handled in sched_fair.c)
  6. */
  7. /*
  8. * Idle tasks are unconditionally rescheduled:
  9. */
  10. static void check_preempt_curr_idle(struct rq *rq, struct task_struct *p)
  11. {
  12. resched_task(rq->idle);
  13. }
  14. static struct task_struct *pick_next_task_idle(struct rq *rq)
  15. {
  16. schedstat_inc(rq, sched_goidle);
  17. return rq->idle;
  18. }
  19. /*
  20. * It is not legal to sleep in the idle task - print a warning
  21. * message if some code attempts to do it:
  22. */
  23. static void
  24. dequeue_task_idle(struct rq *rq, struct task_struct *p, int sleep)
  25. {
  26. spin_unlock_irq(&rq->lock);
  27. printk(KERN_ERR "bad: scheduling from the idle thread!\n");
  28. dump_stack();
  29. spin_lock_irq(&rq->lock);
  30. }
  31. static void put_prev_task_idle(struct rq *rq, struct task_struct *prev)
  32. {
  33. }
  34. #ifdef CONFIG_SMP
  35. static unsigned long
  36. load_balance_idle(struct rq *this_rq, int this_cpu, struct rq *busiest,
  37. unsigned long max_load_move,
  38. struct sched_domain *sd, enum cpu_idle_type idle,
  39. int *all_pinned, int *this_best_prio)
  40. {
  41. return 0;
  42. }
  43. static int
  44. move_one_task_idle(struct rq *this_rq, int this_cpu, struct rq *busiest,
  45. struct sched_domain *sd, enum cpu_idle_type idle)
  46. {
  47. return 0;
  48. }
  49. #endif
  50. static void task_tick_idle(struct rq *rq, struct task_struct *curr)
  51. {
  52. }
  53. static void set_curr_task_idle(struct rq *rq)
  54. {
  55. }
  56. /*
  57. * Simple, special scheduling class for the per-CPU idle tasks:
  58. */
  59. const struct sched_class idle_sched_class = {
  60. /* .next is NULL */
  61. /* no enqueue/yield_task for idle tasks */
  62. /* dequeue is not valid, we print a debug message there: */
  63. .dequeue_task = dequeue_task_idle,
  64. .check_preempt_curr = check_preempt_curr_idle,
  65. .pick_next_task = pick_next_task_idle,
  66. .put_prev_task = put_prev_task_idle,
  67. #ifdef CONFIG_SMP
  68. .load_balance = load_balance_idle,
  69. .move_one_task = move_one_task_idle,
  70. #endif
  71. .set_curr_task = set_curr_task_idle,
  72. .task_tick = task_tick_idle,
  73. /* no .task_new for idle tasks */
  74. };