Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 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 | |
| 10 | #ifdef CONFIG_SMP |
| 11 | static int |
Peter Zijlstra | 7608dec | 2011-04-05 17:23:46 +0200 | [diff] [blame] | 12 | select_task_rq_stop(struct task_struct *p, int sd_flag, int flags) |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 13 | { |
| 14 | return task_cpu(p); /* stop tasks as never migrate */ |
| 15 | } |
| 16 | #endif /* CONFIG_SMP */ |
| 17 | |
| 18 | static void |
| 19 | check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags) |
| 20 | { |
Peter Zijlstra | 1e5a740 | 2010-10-31 12:37:04 +0100 | [diff] [blame] | 21 | /* we're never preempted */ |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | static struct task_struct *pick_next_task_stop(struct rq *rq) |
| 25 | { |
| 26 | struct task_struct *stop = rq->stop; |
| 27 | |
Peter Zijlstra | fd2f441 | 2011-04-05 17:23:44 +0200 | [diff] [blame] | 28 | if (stop && stop->on_rq) |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 29 | return stop; |
| 30 | |
| 31 | return NULL; |
| 32 | } |
| 33 | |
| 34 | static void |
| 35 | enqueue_task_stop(struct rq *rq, struct task_struct *p, int flags) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | static void |
| 40 | dequeue_task_stop(struct rq *rq, struct task_struct *p, int flags) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | static void yield_task_stop(struct rq *rq) |
| 45 | { |
| 46 | BUG(); /* the stop task should never yield, its pointless. */ |
| 47 | } |
| 48 | |
| 49 | static void put_prev_task_stop(struct rq *rq, struct task_struct *prev) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | static void set_curr_task_stop(struct rq *rq) |
| 58 | { |
| 59 | } |
| 60 | |
Peter Zijlstra | da7a735 | 2011-01-17 17:03:27 +0100 | [diff] [blame] | 61 | static void switched_to_stop(struct rq *rq, struct task_struct *p) |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 62 | { |
| 63 | BUG(); /* its impossible to change to this class */ |
| 64 | } |
| 65 | |
Peter Zijlstra | da7a735 | 2011-01-17 17:03:27 +0100 | [diff] [blame] | 66 | static void |
| 67 | prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio) |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 68 | { |
| 69 | BUG(); /* how!?, what priority? */ |
| 70 | } |
| 71 | |
| 72 | static unsigned int |
| 73 | get_rr_interval_stop(struct rq *rq, struct task_struct *task) |
| 74 | { |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | * Simple, special scheduling class for the per-CPU stop tasks: |
| 80 | */ |
| 81 | static const struct sched_class stop_sched_class = { |
| 82 | .next = &rt_sched_class, |
| 83 | |
| 84 | .enqueue_task = enqueue_task_stop, |
| 85 | .dequeue_task = dequeue_task_stop, |
| 86 | .yield_task = yield_task_stop, |
| 87 | |
| 88 | .check_preempt_curr = check_preempt_curr_stop, |
| 89 | |
| 90 | .pick_next_task = pick_next_task_stop, |
| 91 | .put_prev_task = put_prev_task_stop, |
| 92 | |
| 93 | #ifdef CONFIG_SMP |
| 94 | .select_task_rq = select_task_rq_stop, |
| 95 | #endif |
| 96 | |
| 97 | .set_curr_task = set_curr_task_stop, |
| 98 | .task_tick = task_tick_stop, |
| 99 | |
| 100 | .get_rr_interval = get_rr_interval_stop, |
| 101 | |
| 102 | .prio_changed = prio_changed_stop, |
| 103 | .switched_to = switched_to_stop, |
Peter Zijlstra | 34f971f | 2010-09-22 13:53:15 +0200 | [diff] [blame] | 104 | }; |