diff options
-rw-r--r-- | include/litmus/litmus.h | 2 | ||||
-rw-r--r-- | litmus/sched_cedf.c | 4 | ||||
-rw-r--r-- | litmus/sched_gsn_edf.c | 3 | ||||
-rw-r--r-- | litmus/sync.c | 21 |
4 files changed, 18 insertions, 12 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 332606c46e56..7efd146c2198 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -143,7 +143,7 @@ clear_bit(flag_nr, &tsk_rt(t)->budget.flags)) | |||
143 | tsk_rt(t)->budget.flags = 0) | 143 | tsk_rt(t)->budget.flags = 0) |
144 | 144 | ||
145 | #define requeue_preempted_job(t) \ | 145 | #define requeue_preempted_job(t) \ |
146 | (t && (!budget_exhausted(t) || !budget_enforced(t))) | 146 | (t && !is_completed(t) && (!budget_exhausted(t) || !budget_enforced(t))) |
147 | 147 | ||
148 | 148 | ||
149 | #ifdef CONFIG_LITMUS_LOCKING | 149 | #ifdef CONFIG_LITMUS_LOCKING |
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 09caa509a0f4..7d5ca1c49ab8 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c | |||
@@ -380,7 +380,6 @@ static noinline void link_task_to_cpu(struct task_struct* linked, | |||
380 | 380 | ||
381 | /* Link new task to CPU. */ | 381 | /* Link new task to CPU. */ |
382 | if (linked) { | 382 | if (linked) { |
383 | tsk_rt(linked)->completed = 0; | ||
384 | /* handle task is already scheduled somewhere! */ | 383 | /* handle task is already scheduled somewhere! */ |
385 | on_cpu = linked->rt_param.scheduled_on; | 384 | on_cpu = linked->rt_param.scheduled_on; |
386 | if (on_cpu != NO_CPU) { | 385 | if (on_cpu != NO_CPU) { |
@@ -618,7 +617,7 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
618 | now, forced); | 617 | now, forced); |
619 | 618 | ||
620 | /* set flags */ | 619 | /* set flags */ |
621 | tsk_rt(t)->completed = 1; | 620 | tsk_rt(t)->completed = 0; |
622 | 621 | ||
623 | if (!forced && do_backlogged_job) { | 622 | if (!forced && do_backlogged_job) { |
624 | /* Don't advance deadline/refresh budget. Use the remaining budget for | 623 | /* Don't advance deadline/refresh budget. Use the remaining budget for |
@@ -647,7 +646,6 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
647 | unlink(t); | 646 | unlink(t); |
648 | 647 | ||
649 | /* release or arm next job */ | 648 | /* release or arm next job */ |
650 | tsk_rt(t)->completed = 0; | ||
651 | if (is_running(t)) { | 649 | if (is_running(t)) { |
652 | /* is our next job a backlogged job? */ | 650 | /* is our next job a backlogged job? */ |
653 | if (do_backlogged_job) { | 651 | if (do_backlogged_job) { |
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index cad6210d844d..0f96fb7ddb25 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -224,7 +224,6 @@ static noinline void link_task_to_cpu(struct task_struct* linked, | |||
224 | 224 | ||
225 | /* Link new task to CPU. */ | 225 | /* Link new task to CPU. */ |
226 | if (linked) { | 226 | if (linked) { |
227 | tsk_rt(linked)->completed = 0; | ||
228 | /* handle task is already scheduled somewhere! */ | 227 | /* handle task is already scheduled somewhere! */ |
229 | on_cpu = linked->rt_param.scheduled_on; | 228 | on_cpu = linked->rt_param.scheduled_on; |
230 | if (on_cpu != NO_CPU) { | 229 | if (on_cpu != NO_CPU) { |
@@ -408,7 +407,7 @@ static noinline void job_completion(struct task_struct *t, int forced) | |||
408 | TRACE_TASK(t, "job_completion().\n"); | 407 | TRACE_TASK(t, "job_completion().\n"); |
409 | 408 | ||
410 | /* set flags */ | 409 | /* set flags */ |
411 | tsk_rt(t)->completed = 1; | 410 | tsk_rt(t)->completed = 0; |
412 | /* prepare for next period */ | 411 | /* prepare for next period */ |
413 | prepare_for_next_period(t); | 412 | prepare_for_next_period(t); |
414 | if (is_early_releasing(t) || is_released(t, litmus_clock())) | 413 | if (is_early_releasing(t) || is_released(t, litmus_clock())) |
diff --git a/litmus/sync.c b/litmus/sync.c index 01ea5d52f84b..93b7207b9361 100644 --- a/litmus/sync.c +++ b/litmus/sync.c | |||
@@ -55,14 +55,23 @@ static long do_wait_for_ts_release(struct timespec *wake) | |||
55 | + current->rt_param.task_params.phase; | 55 | + current->rt_param.task_params.phase; |
56 | *wake = ns_to_timespec(phasedRelease); | 56 | *wake = ns_to_timespec(phasedRelease); |
57 | 57 | ||
58 | /* Completion succeeded, setup release. */ | 58 | /* Setting this flag before releasing ensures that this CPU |
59 | litmus->release_at(current, phasedRelease | 59 | * will be the next CPU to requeue the task on a ready or |
60 | - current->rt_param.task_params.period); | 60 | * release queue. |
61 | /* trigger advance to next job release at the programmed time */ | 61 | */ |
62 | ret = complete_job(); | 62 | tsk_rt(current)->completed = 1; |
63 | mb(); | ||
64 | |||
65 | /* completion succeeded, set up release. subtract off | ||
66 | * period because schedule()->job_completion() will | ||
67 | * advances us to the correct time */ | ||
68 | litmus->release_at(current, | ||
69 | phasedRelease - current->rt_param.task_params.period); | ||
70 | schedule(); | ||
63 | } | 71 | } |
64 | else | 72 | else { |
65 | *wake = ns_to_timespec(wait.ts_release_time); | 73 | *wake = ns_to_timespec(wait.ts_release_time); |
74 | } | ||
66 | } else { | 75 | } else { |
67 | /* We were interrupted, must cleanup list. */ | 76 | /* We were interrupted, must cleanup list. */ |
68 | mutex_lock(&task_release_lock); | 77 | mutex_lock(&task_release_lock); |