diff options
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r-- | firmware/kernel.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index 4d2f519171..3255ba0b20 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -59,13 +59,15 @@ void sleep(int ticks) | |||
59 | int timeout = current_tick + ticks + 1; | 59 | int timeout = current_tick + ticks + 1; |
60 | 60 | ||
61 | while (TIME_BEFORE( current_tick, timeout )) { | 61 | while (TIME_BEFORE( current_tick, timeout )) { |
62 | yield(); | 62 | sleep_thread(); |
63 | } | 63 | } |
64 | wake_up_thread(); | ||
64 | } | 65 | } |
65 | 66 | ||
66 | void yield(void) | 67 | void yield(void) |
67 | { | 68 | { |
68 | switch_thread(); | 69 | switch_thread(); |
70 | wake_up_thread(); | ||
69 | } | 71 | } |
70 | 72 | ||
71 | /**************************************************************************** | 73 | /**************************************************************************** |
@@ -96,8 +98,9 @@ void queue_wait(struct event_queue *q, struct event *ev) | |||
96 | { | 98 | { |
97 | while(q->read == q->write) | 99 | while(q->read == q->write) |
98 | { | 100 | { |
99 | switch_thread(); | 101 | sleep_thread(); |
100 | } | 102 | } |
103 | wake_up_thread(); | ||
101 | 104 | ||
102 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; | 105 | *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; |
103 | } | 106 | } |
@@ -108,8 +111,9 @@ void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks) | |||
108 | 111 | ||
109 | while(q->read == q->write && TIME_BEFORE( current_tick, timeout )) | 112 | while(q->read == q->write && TIME_BEFORE( current_tick, timeout )) |
110 | { | 113 | { |
111 | switch_thread(); | 114 | sleep_thread(); |
112 | } | 115 | } |
116 | wake_up_thread(); | ||
113 | 117 | ||
114 | if(q->read != q->write) | 118 | if(q->read != q->write) |
115 | { | 119 | { |
@@ -201,6 +205,7 @@ void IMIA0(void) | |||
201 | } | 205 | } |
202 | 206 | ||
203 | current_tick++; | 207 | current_tick++; |
208 | wake_up_thread(); | ||
204 | 209 | ||
205 | TSR0 &= ~0x01; | 210 | TSR0 &= ~0x01; |
206 | } | 211 | } |
@@ -257,7 +262,8 @@ void mutex_lock(struct mutex *m) | |||
257 | { | 262 | { |
258 | /* Wait until the lock is open... */ | 263 | /* Wait until the lock is open... */ |
259 | while(m->locked) | 264 | while(m->locked) |
260 | yield(); | 265 | sleep_thread(); |
266 | wake_up_thread(); | ||
261 | 267 | ||
262 | /* ...and lock it */ | 268 | /* ...and lock it */ |
263 | m->locked = true; | 269 | m->locked = true; |