diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-10 15:34:07 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-10 15:34:07 -0400 |
commit | d6c62a40cd5378f816a81ef62b34357614c5d21e (patch) | |
tree | c7457ec787c5bde98b242b3cfb4eb7ae53d4ecd6 | |
parent | bed39605a721d5648cd9ee5bc5a3acafc53e972c (diff) |
LITMUS Core: delay migration until context switch is complete
Also:
- add some memory barriers, to be on the safe side
- fix some line breaks
-rw-r--r-- | litmus/sched_litmus.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/litmus/sched_litmus.c b/litmus/sched_litmus.c index 0e6cde6e1f..1e541e4ac0 100644 --- a/litmus/sched_litmus.c +++ b/litmus/sched_litmus.c | |||
@@ -45,6 +45,7 @@ static void litmus_schedule(struct rq *rq, struct task_struct *prev) | |||
45 | * state | 45 | * state |
46 | */ | 46 | */ |
47 | prev_state = prev->state; | 47 | prev_state = prev->state; |
48 | mb(); | ||
48 | spin_unlock(&rq->lock); | 49 | spin_unlock(&rq->lock); |
49 | 50 | ||
50 | /* Don't race with a concurrent switch. | 51 | /* Don't race with a concurrent switch. |
@@ -61,12 +62,14 @@ static void litmus_schedule(struct rq *rq, struct task_struct *prev) | |||
61 | cpu_relax(); | 62 | cpu_relax(); |
62 | mb(); | 63 | mb(); |
63 | if (rq->litmus_next->rt_param.stack_in_use == NO_CPU) | 64 | if (rq->litmus_next->rt_param.stack_in_use == NO_CPU) |
64 | TRACE_TASK(rq->litmus_next, "descheduled. Proceeding.\n"); | 65 | TRACE_TASK(rq->litmus_next, |
66 | "descheduled. Proceeding.\n"); | ||
65 | if (lt_before(_maybe_deadlock + 10000000, litmus_clock())) { | 67 | if (lt_before(_maybe_deadlock + 10000000, litmus_clock())) { |
66 | /* We've been spinning for 10ms. | 68 | /* We've been spinning for 10ms. |
67 | * Something can't be right! | 69 | * Something can't be right! |
68 | * Let's abandon the task and bail out; at least | 70 | * Let's abandon the task and bail out; at least |
69 | * we will have debug info instead of a hard deadlock. | 71 | * we will have debug info instead of a hard |
72 | * deadlock. | ||
70 | */ | 73 | */ |
71 | TRACE_TASK(rq->litmus_next, | 74 | TRACE_TASK(rq->litmus_next, |
72 | "stack too long in use. Deadlock?\n"); | 75 | "stack too long in use. Deadlock?\n"); |
@@ -77,8 +80,16 @@ static void litmus_schedule(struct rq *rq, struct task_struct *prev) | |||
77 | return; | 80 | return; |
78 | } | 81 | } |
79 | } | 82 | } |
80 | 83 | #ifdef __ARCH_WANT_UNLOCKED_CTXSW | |
84 | if (rq->litmus_next->oncpu) | ||
85 | TRACE_TASK(rq->litmus_next, "waiting for !oncpu"); | ||
86 | while (rq->litmus_next->oncpu) { | ||
87 | cpu_relax(); | ||
88 | mb(); | ||
89 | } | ||
90 | #endif | ||
81 | double_rq_lock(rq, other_rq); | 91 | double_rq_lock(rq, other_rq); |
92 | mb(); | ||
82 | if (prev->state != prev_state && is_realtime(prev)) { | 93 | if (prev->state != prev_state && is_realtime(prev)) { |
83 | TRACE_TASK(prev, | 94 | TRACE_TASK(prev, |
84 | "state changed while we dropped" | 95 | "state changed while we dropped" |