Index: emcore/trunk/target/ipodnano2g/timer.c |
— | — | @@ -46,5 +46,5 @@ |
47 | 47 | void INT_TIMERB(void)
|
48 | 48 | {
|
49 | 49 | TBCON = TBCON;
|
50 | | - scheduler_switch(NULL);
|
| 50 | + scheduler_switch(NULL, NULL);
|
51 | 51 | }
|
Index: emcore/trunk/target/ipodnano3g/timer.c |
— | — | @@ -52,5 +52,5 @@ |
53 | 53 | void INT_TIMERB(void)
|
54 | 54 | {
|
55 | 55 | TBCON = TBCON;
|
56 | | - scheduler_switch(NULL);
|
| 56 | + scheduler_switch(NULL, NULL);
|
57 | 57 | }
|
Index: emcore/trunk/target/ipodnano4g/timer.c |
— | — | @@ -53,5 +53,5 @@ |
54 | 54 | void INT_TIMERB(void)
|
55 | 55 | {
|
56 | 56 | TBCON = TBCON;
|
57 | | - scheduler_switch(NULL);
|
| 57 | + scheduler_switch(NULL, NULL);
|
58 | 58 | }
|
Index: emcore/trunk/arm/contextswitch.S |
— | — | @@ -32,13 +32,15 @@ |
33 | 33 | msr cpsr_c, #0xdf
|
34 | 34 | ldr r0, =current_thread
|
35 | 35 | ldr r0, [r0]
|
36 | | - stmia r0!, {r0-r14}
|
37 | | - str lr, [r0], #4
|
38 | | - str r1, [r0]
|
| 36 | + stmia r0, {r0-r14}
|
| 37 | + str lr, [r0,#0x3c]
|
| 38 | + str r1, [r0,#0x40]
|
39 | 39 | msr cpsr_c, #0xd2
|
| 40 | + mov r4, r0
|
40 | 41 | bl scheduler_pause_accounting
|
41 | 42 | adr lr, resume_thread
|
42 | | - mov r0, #-1
|
| 43 | + mov r0, #0
|
| 44 | + mov r1, r4
|
43 | 45 | b scheduler_switch
|
44 | 46 | .size yield, .-yield
|
45 | 47 |
|
— | — | @@ -80,7 +82,8 @@ |
81 | 83 | stmia r5, {r0-r4}
|
82 | 84 | bl scheduler_pause_accounting
|
83 | 85 | adr lr, resume_thread
|
84 | | - mov r0, #-1
|
| 86 | + mov r0, #0
|
| 87 | + mov r1, #0
|
85 | 88 | b scheduler_switch
|
86 | 89 | .size syscall_handler, .-syscall_handler
|
87 | 90 |
|
Index: emcore/trunk/thread.c |
— | — | @@ -258,7 +258,7 @@ |
259 | 259 | current_thread->startusec = USEC_TIMER;
|
260 | 260 | }
|
261 | 261 |
|
262 | | -void scheduler_switch(struct scheduler_thread* thread)
|
| 262 | +void scheduler_switch(struct scheduler_thread* thread, struct scheduler_thread* block)
|
263 | 263 | {
|
264 | 264 | struct scheduler_thread* t;
|
265 | 265 | uint32_t score, best;
|
— | — | @@ -273,7 +273,6 @@ |
274 | 274 | current_thread->block_type = THREAD_DEFUNCT_STKOV;
|
275 | 275 | wakeup_signal(&dbgwakeup);
|
276 | 276 | }
|
277 | | -
|
278 | 277 | if (usec - last_tick > SCHEDULER_TICK)
|
279 | 278 | {
|
280 | 279 | uint32_t diff = usec - last_tick;
|
— | — | @@ -300,8 +299,7 @@ |
301 | 300 | t->timeout = 0;
|
302 | 301 | }
|
303 | 302 |
|
304 | | - if (thread && thread->state == THREAD_READY) current_thread = thread;
|
305 | | - else
|
| 303 | + if (!thread || thread->state != THREAD_READY)
|
306 | 304 | {
|
307 | 305 | thread = &idle_thread;
|
308 | 306 | best = 0xffffffff;
|
— | — | @@ -308,7 +306,8 @@ |
309 | 307 | for (t = head_thread; t; t = t->thread_next)
|
310 | 308 | if (t->state == THREAD_READY && t->priority)
|
311 | 309 | {
|
312 | | - score = t->cputime_current / t->priority;
|
| 310 | + if (t == block) score = 0xfffffffe;
|
| 311 | + else score = t->cputime_current / t->priority;
|
313 | 312 | if (score < best)
|
314 | 313 | {
|
315 | 314 | best = score;
|
Index: emcore/trunk/usb/usb.c |
— | — | @@ -518,7 +518,7 @@ |
519 | 519 | break;
|
520 | 520 | case 16: // FREEZE SCHEDULER
|
521 | 521 | dbgsendbuf[1] = scheduler_freeze(dbgrecvbuf[1]);
|
522 | | - scheduler_switch(NULL);
|
| 522 | + scheduler_switch(NULL, NULL);
|
523 | 523 | dbgsendbuf[0] = 1;
|
524 | 524 | size = 16;
|
525 | 525 | break;
|
Index: emcore/trunk/thread.h |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | void scheduler_init() INITCODE_ATTR;
|
115 | 115 | void scheduler_pause_accounting() ICODE_ATTR;
|
116 | 116 | void scheduler_resume_accounting() ICODE_ATTR;
|
117 | | -void scheduler_switch(struct scheduler_thread* thread) ICODE_ATTR;
|
| 117 | +void scheduler_switch(struct scheduler_thread* thread, struct scheduler_thread* block) ICODE_ATTR;
|
118 | 118 | bool scheduler_freeze(bool value);
|
119 | 119 | struct scheduler_thread* thread_create(struct scheduler_thread* thread, const char* name,
|
120 | 120 | const void* code, void* stack, int stacksize,
|