diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-16 17:44:37 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-16 17:44:37 -0400 |
commit | 4e8f9b7c2e9134ca31feb91dee3609a95df6de56 (patch) | |
tree | 1e7a115068299b0fce7b8369731ed74bffa1a3c7 /litmus/preempt.c | |
parent | 4ad6ba08f0dab67bbd89a26b27f1cc86e3c45c13 (diff) |
Implement real-time aux threads. G-EDF only.
Diffstat (limited to 'litmus/preempt.c')
-rw-r--r-- | litmus/preempt.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/litmus/preempt.c b/litmus/preempt.c index a2cae3648e15..c9ccc80c1df9 100644 --- a/litmus/preempt.c +++ b/litmus/preempt.c | |||
@@ -74,25 +74,37 @@ void litmus_reschedule(int cpu) | |||
74 | * is not aware of the need to reschedule at this point. */ | 74 | * is not aware of the need to reschedule at this point. */ |
75 | 75 | ||
76 | /* is a context switch in progress? */ | 76 | /* is a context switch in progress? */ |
77 | if (cpu_is_in_sched_state(cpu, TASK_PICKED)) | 77 | if (cpu_is_in_sched_state(cpu, TASK_PICKED)) { |
78 | picked_transition_ok = sched_state_transition_on( | 78 | picked_transition_ok = sched_state_transition_on( |
79 | cpu, TASK_PICKED, PICKED_WRONG_TASK); | 79 | cpu, TASK_PICKED, PICKED_WRONG_TASK); |
80 | 80 | ||
81 | TRACE_CUR("cpu %d: picked_transition_ok = %d\n", cpu, picked_transition_ok); | ||
82 | } | ||
83 | else { | ||
84 | TRACE_CUR("cpu %d: picked_transition_ok = 0 (static)\n", cpu); | ||
85 | } | ||
86 | |||
81 | if (!picked_transition_ok && | 87 | if (!picked_transition_ok && |
82 | cpu_is_in_sched_state(cpu, TASK_SCHEDULED)) { | 88 | cpu_is_in_sched_state(cpu, TASK_SCHEDULED)) { |
83 | /* We either raced with the end of the context switch, or the | 89 | /* We either raced with the end of the context switch, or the |
84 | * CPU was in TASK_SCHEDULED anyway. */ | 90 | * CPU was in TASK_SCHEDULED anyway. */ |
85 | scheduled_transition_ok = sched_state_transition_on( | 91 | scheduled_transition_ok = sched_state_transition_on( |
86 | cpu, TASK_SCHEDULED, SHOULD_SCHEDULE); | 92 | cpu, TASK_SCHEDULED, SHOULD_SCHEDULE); |
93 | TRACE_CUR("cpu %d: scheduled_transition_ok = %d\n", cpu, scheduled_transition_ok); | ||
94 | } | ||
95 | else { | ||
96 | TRACE_CUR("cpu %d: scheduled_transition_ok = 0 (static)\n", cpu); | ||
87 | } | 97 | } |
88 | 98 | ||
89 | /* If the CPU was in state TASK_SCHEDULED, then we need to cause the | 99 | /* If the CPU was in state TASK_SCHEDULED, then we need to cause the |
90 | * scheduler to be invoked. */ | 100 | * scheduler to be invoked. */ |
91 | if (scheduled_transition_ok) { | 101 | if (scheduled_transition_ok) { |
92 | if (smp_processor_id() == cpu) | 102 | if (smp_processor_id() == cpu) { |
93 | set_tsk_need_resched(current); | 103 | set_tsk_need_resched(current); |
94 | else | 104 | } |
105 | else { | ||
95 | smp_send_reschedule(cpu); | 106 | smp_send_reschedule(cpu); |
107 | } | ||
96 | } | 108 | } |
97 | 109 | ||
98 | TRACE_STATE("%s picked-ok:%d sched-ok:%d\n", | 110 | TRACE_STATE("%s picked-ok:%d sched-ok:%d\n", |
@@ -103,11 +115,16 @@ void litmus_reschedule(int cpu) | |||
103 | 115 | ||
104 | void litmus_reschedule_local(void) | 116 | void litmus_reschedule_local(void) |
105 | { | 117 | { |
106 | if (is_in_sched_state(TASK_PICKED)) | 118 | if (is_in_sched_state(TASK_PICKED)) { |
107 | set_sched_state(PICKED_WRONG_TASK); | 119 | set_sched_state(PICKED_WRONG_TASK); |
120 | |||
121 | TRACE_CUR("cpu %d: transitioned to PICKED_WRONG_TASK\n", smp_processor_id()); | ||
122 | } | ||
108 | else if (is_in_sched_state(TASK_SCHEDULED | SHOULD_SCHEDULE)) { | 123 | else if (is_in_sched_state(TASK_SCHEDULED | SHOULD_SCHEDULE)) { |
109 | set_sched_state(WILL_SCHEDULE); | 124 | set_sched_state(WILL_SCHEDULE); |
110 | set_tsk_need_resched(current); | 125 | set_tsk_need_resched(current); |
126 | |||
127 | TRACE_CUR("cpu %d: transitioned to WILL_SCHEDULE\n", smp_processor_id()); | ||
111 | } | 128 | } |
112 | } | 129 | } |
113 | 130 | ||