kernel/eka/nkernsmp/nkerns.cpp
changeset 177 a232af6b0b1f
parent 90 947f0dc9f7a8
child 300 1d28c8722707
--- a/kernel/eka/nkernsmp/nkerns.cpp	Wed Jun 23 12:52:28 2010 +0100
+++ b/kernel/eka/nkernsmp/nkerns.cpp	Wed Jun 23 12:58:21 2010 +0100
@@ -242,8 +242,8 @@
 		iCurrent = iReady;
 		iCpuAffinity = iLastCpu;
 		iEventState = (iLastCpu<<EEventCpuShift) | (iLastCpu<<EThreadCpuShift);
-		ss.SSAddEntry(this);
-		i_NThread_Initial = TRUE;
+		i_NThread_Initial = TRUE;	// must set initial thread flag before adding to subscheduler
+		ss.SSAddEntry(this);		// in order to get correct ready thread count (i.e. not including the idle thread)
 		iACount = 1;
 		ss.iInitialThread = (NThread*)this;
 		NKern::Unlock();		// now that current thread is defined
@@ -538,6 +538,7 @@
 
 NThread* TScheduler::LBThread()
 	{
-	return (NThread*)(TheScheduler.iRebalanceDfcQ->iThread);
+	TDfcQue* rbQ = TheScheduler.iRebalanceDfcQ;
+	return rbQ ? (NThread*)(rbQ->iThread) : 0;
 	}