aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJohn M. Calandrino <jmc@jupiter-cs.cs.unc.edu>2007-04-25 19:37:01 -0400
committerJohn M. Calandrino <jmc@jupiter-cs.cs.unc.edu>2007-04-25 19:37:01 -0400
commitd7718a1d5a09e0f8c698886c85c0c41ee88a51f4 (patch)
treea271ecd6f7d7d9b4c735b42f126cfb53ce36fe2c /kernel
parent3115fffc3483ee16b3012f95c814d4e219057bb9 (diff)
parent50e4938993cbb7ce43566c18d7d6616b2b8c61d6 (diff)
Merge with git+ssh://cvs.cs.unc.edu/cvs/proj/litmus/repo/litmus
Diffstat (limited to 'kernel')
-rw-r--r--kernel/edf_common.c35
-rw-r--r--kernel/sched_gsn_edf.c15
2 files changed, 32 insertions, 18 deletions
diff --git a/kernel/edf_common.c b/kernel/edf_common.c
index 129efe408e..20d990e30f 100644
--- a/kernel/edf_common.c
+++ b/kernel/edf_common.c
@@ -91,17 +91,23 @@ void __add_ready(edf_domain_t* edf, struct task_struct *new)
91 91
92struct task_struct* __take_ready(edf_domain_t* edf) 92struct task_struct* __take_ready(edf_domain_t* edf)
93{ 93{
94 struct task_struct *t = __peek_ready(edf);
95
96 /* kick it out of the ready list */
97 if (t)
98 list_del(&t->rt_list);
99 return t;
100}
101
102
103struct task_struct* __peek_ready(edf_domain_t* edf)
104{
94 struct task_struct *t = NULL; 105 struct task_struct *t = NULL;
95 /* either not yet released, preempted, or non-rt */ 106 /* either not yet released, preempted, or non-rt */
96 if (!list_empty(&edf->ready_queue)) { 107 if (!list_empty(&edf->ready_queue))
97
98 /* take next rt task */ 108 /* take next rt task */
99 t = list_entry(edf->ready_queue.next, struct task_struct, 109 t = list_entry(edf->ready_queue.next, struct task_struct,
100 rt_list); 110 rt_list);
101
102 /* kick it out of the ready list */
103 list_del(&t->rt_list);
104 }
105 return t; 111 return t;
106} 112}
107 113
@@ -234,13 +240,16 @@ void __prepare_new_releases(edf_domain_t *edf, jiffie_t start)
234int preemption_needed(edf_domain_t* edf, struct task_struct *t) 240int preemption_needed(edf_domain_t* edf, struct task_struct *t)
235{ 241{
236 /* we need the read lock for edf_ready_queue */ 242 /* we need the read lock for edf_ready_queue */
237 if (!list_empty(&edf->ready_queue) || is_np(t)) 243 /* no need to preempt if there is nothing pending */
238 { 244 if (list_empty(&edf->ready_queue))
239 if (is_realtime(t)) 245 return 0;
240 return edf_higher_prio(next_ready(edf), t); 246 /* we need to reschedule if t doesn't exist */
241 else 247 if (!t)
242 return 1; 248 return 1;
243 } 249 /* don't preempt if t is non-preemptable */
250 if (!is_np(t))
251 /* make sure to get non-rt stuff out of the way */
252 return !is_realtime(t) || edf_higher_prio(next_ready(edf), t);
244 return 0; 253 return 0;
245} 254}
246 255
diff --git a/kernel/sched_gsn_edf.c b/kernel/sched_gsn_edf.c
index 11cf1a7273..a2261cce91 100644
--- a/kernel/sched_gsn_edf.c
+++ b/kernel/sched_gsn_edf.c
@@ -194,16 +194,21 @@ static noinline void gsnedf_job_arrival(struct task_struct* task)
194 194
195 BUG_ON(list_empty(&gsnedf_cpu_queue)); 195 BUG_ON(list_empty(&gsnedf_cpu_queue));
196 BUG_ON(!task); 196 BUG_ON(!task);
197 last = list_entry(gsnedf_cpu_queue.prev, cpu_entry_t, list);
198 197
199 if (is_released(task) && edf_higher_prio(task, last->linked)) { 198 /* first queue arriving job */
200 TRACE("arriving task %d linked to %d\n", task->pid, last->cpu); 199 requeue(task);
200
201 /* then check for any necessary preemptions */
202 last = list_entry(gsnedf_cpu_queue.prev, cpu_entry_t, list);
203 if (preemption_needed(&gsnedf, last->linked)) {
204 /* preemption necessary */
205 task = __take_ready(&gsnedf);
206 TRACE("job_arrival: task %d linked to %d\n", task->pid, last->cpu);
201 if (last->linked) 207 if (last->linked)
202 requeue(last->linked); 208 requeue(last->linked);
203 link_task_to_cpu(task, last); 209 link_task_to_cpu(task, last);
204 preempt(last); 210 preempt(last);
205 } else 211 }
206 requeue(task);
207} 212}
208 213
209/* check for current job releases */ 214/* check for current job releases */