kernel/eka/nkern/arm/ncsched.cia
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
   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 
       
   456 #ifdef _DEBUG
   451 #ifdef _DEBUG
   457 	asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(NThread,iHeldFastMutex));
   452 	asm("ldr r2, [r1, #%a0]" : : "i" _FOFF(NThread,iHeldFastMutex));
   458 	asm("mov r12, #0xd8000003 ");
   453 	asm("mov r12, #0xd8000003 ");
   459 	asm("cmp r2, #0 ");
   454 	asm("cmp r2, #0 ");
   460 	asm("strne r12, [r12] ");				// crash if fast mutex held
   455 	asm("strne r12, [r12] ");				// crash if fast mutex held
   612 
   607 
   613 __NAKED__ void NThreadBase::DoReady()
   608 __NAKED__ void NThreadBase::DoReady()
   614 	{
   609 	{
   615 	asm("ldr r1, __TheScheduler ");
   610 	asm("ldr r1, __TheScheduler ");
   616 	asm("ldrb r2, [r0, #%a0]" : : "i" _FOFF(NThread,iPriority));	// r2=priority of aThread
   611 	asm("ldrb r2, [r0, #%a0]" : : "i" _FOFF(NThread,iPriority));	// r2=priority of aThread
   617 
       
   618 	asm("DoReadyInner: ");
   612 	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 
       
   623 	asm("mov r3, #%a0" : : "i" (NThread::EReady));
   613 	asm("mov r3, #%a0" : : "i" (NThread::EReady));
   624 	asm("strb r3, [r0, #%a0]" : : "i" _FOFF(NThread,iNState));
   614 	asm("strb r3, [r0, #%a0]" : : "i" _FOFF(NThread,iNState));
   625 	asm("ldmia r1!, {r3,r12} ");			// r3=present mask low, r12=present mask high, r1=&iQueue[0]
   615 	asm("ldmia r1!, {r3,r12} ");			// r3=present mask low, r12=present mask high, r1=&iQueue[0]
   626 	asm("cmp r2, #31 ");
   616 	asm("cmp r2, #31 ");
   627 	asm("bhi 1f ");
   617 	asm("bhi 1f ");
  1657 	asm("b switch_threads_2 ");
  1647 	asm("b switch_threads_2 ");
  1658 #endif	// __MEMMODEL_MULTIPLE__ || __MEMMODEL_FLEXIBLE__
  1648 #endif	// __MEMMODEL_MULTIPLE__ || __MEMMODEL_FLEXIBLE__
  1659 
  1649 
  1660 	asm("round_robin: ");					// get here if thread's timeslice has expired and there is another
  1650 	asm("round_robin: ");					// get here if thread's timeslice has expired and there is another
  1661 											// thread ready at the same priority
  1651 											// 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 
       
  1667 	asm("cmp r7, #0 ");						// does this thread hold a fast mutex?
  1652 	asm("cmp r7, #0 ");						// does this thread hold a fast mutex?
  1668 	asm("bne rr_holds_fast_mutex ");
  1653 	asm("bne rr_holds_fast_mutex ");
  1669 	asm("ldr lr, [r2, #%a0]" : : "i" _FOFF(NThread,iTimeslice));
  1654 	asm("ldr lr, [r2, #%a0]" : : "i" _FOFF(NThread,iTimeslice));
  1670 	asm("add r0, r0, #%a0" : : "i" _FOFF(TScheduler,iQueue));
  1655 	asm("add r0, r0, #%a0" : : "i" _FOFF(TScheduler,iQueue));
  1671 	asm("str r3, [r0, r12, lsl #2] ");		// first thread at this priority is now the next one
  1656 	asm("str r3, [r0, r12, lsl #2] ");		// first thread at this priority is now the next one