446 // |
446 // |
447 // Remove a thread from the ready list |
447 // Remove a thread from the ready list |
448 // |
448 // |
449 { |
449 { |
450 asm("unready: "); |
450 asm("unready: "); |
|
451 |
|
452 asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(TScheduler,iMadeUnReadyCounter)); // Update Made UnReady count here, |
|
453 asm("add r2, r2, #1"); // ie equiv of 'iMadeUnReadyCounter++;'. |
|
454 asm("str r2, [r0, #%a0]" : : "i" _FOFF(TScheduler,iMadeUnReadyCounter)); |
|
455 |
451 #ifdef _DEBUG |
456 #ifdef _DEBUG |
452 asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(NThread,iHeldFastMutex)); |
457 asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(NThread,iHeldFastMutex)); |
453 asm("mov r12, #0xd8000003 "); |
458 asm("mov r12, #0xd8000003 "); |
454 asm("cmp r2, #0 "); |
459 asm("cmp r2, #0 "); |
455 asm("strne r12, [r12] "); // crash if fast mutex held |
460 asm("strne r12, [r12] "); // crash if fast mutex held |
607 |
612 |
608 __NAKED__ void NThreadBase::DoReady() |
613 __NAKED__ void NThreadBase::DoReady() |
609 { |
614 { |
610 asm("ldr r1, __TheScheduler "); |
615 asm("ldr r1, __TheScheduler "); |
611 asm("ldrb r2, [r0, #%a0]" : : "i" _FOFF(NThread,iPriority)); // r2=priority of aThread |
616 asm("ldrb r2, [r0, #%a0]" : : "i" _FOFF(NThread,iPriority)); // r2=priority of aThread |
|
617 |
612 asm("DoReadyInner: "); |
618 asm("DoReadyInner: "); |
|
619 asm("ldr r3, [r1, #%a0]" : : "i" _FOFF(TScheduler,iMadeReadyCounter)); // Update Made Ready count here, |
|
620 asm("add r3, r3, #1"); // ie equiv of 'iMadeReadyCounter++;'. |
|
621 asm("str r3, [r1, #%a0]" : : "i" _FOFF(TScheduler,iMadeReadyCounter)); |
|
622 |
613 asm("mov r3, #%a0" : : "i" (NThread::EReady)); |
623 asm("mov r3, #%a0" : : "i" (NThread::EReady)); |
614 asm("strb r3, [r0, #%a0]" : : "i" _FOFF(NThread,iNState)); |
624 asm("strb r3, [r0, #%a0]" : : "i" _FOFF(NThread,iNState)); |
615 asm("ldmia r1!, {r3,r12} "); // r3=present mask low, r12=present mask high, r1=&iQueue[0] |
625 asm("ldmia r1!, {r3,r12} "); // r3=present mask low, r12=present mask high, r1=&iQueue[0] |
616 asm("cmp r2, #31 "); |
626 asm("cmp r2, #31 "); |
617 asm("bhi 1f "); |
627 asm("bhi 1f "); |
1647 asm("b switch_threads_2 "); |
1657 asm("b switch_threads_2 "); |
1648 #endif // __MEMMODEL_MULTIPLE__ || __MEMMODEL_FLEXIBLE__ |
1658 #endif // __MEMMODEL_MULTIPLE__ || __MEMMODEL_FLEXIBLE__ |
1649 |
1659 |
1650 asm("round_robin: "); // get here if thread's timeslice has expired and there is another |
1660 asm("round_robin: "); // get here if thread's timeslice has expired and there is another |
1651 // thread ready at the same priority |
1661 // thread ready at the same priority |
|
1662 |
|
1663 asm("ldr r6, [r0, #%a0]" : : "i" _FOFF(TScheduler,iTimeSliceExpireCounter)); // Update Time Slice Expire count here, |
|
1664 asm("add r6,r6, #1"); // ie equiv of 'iTimeSliceExpireCounter++;'. |
|
1665 asm("str r6, [r0, #%a0]" : : "i" _FOFF(TScheduler,iTimeSliceExpireCounter)); |
|
1666 |
1652 asm("cmp r7, #0 "); // does this thread hold a fast mutex? |
1667 asm("cmp r7, #0 "); // does this thread hold a fast mutex? |
1653 asm("bne rr_holds_fast_mutex "); |
1668 asm("bne rr_holds_fast_mutex "); |
1654 asm("ldr lr, [r2, #%a0]" : : "i" _FOFF(NThread,iTimeslice)); |
1669 asm("ldr lr, [r2, #%a0]" : : "i" _FOFF(NThread,iTimeslice)); |
1655 asm("add r0, r0, #%a0" : : "i" _FOFF(TScheduler,iQueue)); |
1670 asm("add r0, r0, #%a0" : : "i" _FOFF(TScheduler,iQueue)); |
1656 asm("str r3, [r0, r12, lsl #2] "); // first thread at this priority is now the next one |
1671 asm("str r3, [r0, r12, lsl #2] "); // first thread at this priority is now the next one |