sched_idletask.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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, u64 now)
  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, u64 now)
  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, u64 now)
  32. {
  33. }
  34. static int
  35. load_balance_idle(struct rq *this_rq, int this_cpu, struct rq *busiest,
  36. unsigned long max_nr_move, unsigned long max_load_move,
  37. struct sched_domain *sd, enum cpu_idle_type idle,
  38. int *all_pinned, unsigned long *total_load_moved)
  39. {
  40. return 0;
  41. }
  42. static void task_tick_idle(struct rq *rq, struct task_struct *curr)
  43. {
  44. }
  45. /*
  46. * Simple, special scheduling class for the per-CPU idle tasks:
  47. */
  48. static struct sched_class idle_sched_class __read_mostly = {
  49. /* no enqueue/yield_task for idle tasks */
  50. /* dequeue is not valid, we print a debug message there: */
  51. .dequeue_task = dequeue_task_idle,
  52. .check_preempt_curr = check_preempt_curr_idle,
  53. .pick_next_task = pick_next_task_idle,
  54. .put_prev_task = put_prev_task_idle,
  55. .load_balance = load_balance_idle,
  56. .task_tick = task_tick_idle,
  57. /* no .task_new for idle tasks */
  58. };