summaryrefslogtreecommitdiff
path: root/firmware/kernel.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-02-14 09:44:34 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-02-14 09:44:34 +0000
commitc4d8d970f6602c80d7362a41da8851dbbf59ae1b (patch)
tree7e8f936eae5c1854c006c4fe134c4c2ce6f91291 /firmware/kernel.c
parent84706a4188cea193a5a095855c1068b1c31a3875 (diff)
downloadrockbox-c4d8d970f6602c80d7362a41da8851dbbf59ae1b.tar.gz
rockbox-c4d8d970f6602c80d7362a41da8851dbbf59ae1b.zip
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.c14
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
66void yield(void) 67void 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;