diff options
author | Björn Stenberg <bjorn@haxx.se> | 2003-02-14 09:44:34 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2003-02-14 09:44:34 +0000 |
commit | c4d8d970f6602c80d7362a41da8851dbbf59ae1b (patch) | |
tree | 7e8f936eae5c1854c006c4fe134c4c2ce6f91291 /firmware/kernel.c | |
parent | 84706a4188cea193a5a095855c1068b1c31a3875 (diff) |
The power-saving SLEEP patch by Simon Elén.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3259 a1c6a512-1295-4272-9138-f99709370657
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) int timeout = current_tick + ticks + 1; while (TIME_BEFORE( current_tick, timeout )) { - yield(); + sleep_thread(); } + wake_up_thread(); } void yield(void) { switch_thread(); + wake_up_thread(); } /**************************************************************************** @@ -96,8 +98,9 @@ void queue_wait(struct event_queue *q, struct event *ev) { while(q->read == q->write) { - switch_thread(); + sleep_thread(); } + wake_up_thread(); *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; } @@ -108,8 +111,9 @@ void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks) while(q->read == q->write && TIME_BEFORE( current_tick, timeout )) { - switch_thread(); + sleep_thread(); } + wake_up_thread(); if(q->read != q->write) { @@ -201,6 +205,7 @@ void IMIA0(void) } current_tick++; + wake_up_thread(); TSR0 &= ~0x01; } @@ -257,7 +262,8 @@ void mutex_lock(struct mutex *m) { /* Wait until the lock is open... */ while(m->locked) - yield(); + sleep_thread(); + wake_up_thread(); /* ...and lock it */ m->locked = true; |