kernel/eka/kernel/sinit.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 39 2bb754abd467
child 44 3e88ff8f41d5
--- a/kernel/eka/kernel/sinit.cpp	Thu Aug 19 11:14:22 2010 +0300
+++ b/kernel/eka/kernel/sinit.cpp	Tue Aug 31 16:34:26 2010 +0300
@@ -45,6 +45,11 @@
 const TInt KDfcThread1Priority=48;
 const TInt KMaxEventQueue=40;
 
+#ifdef __SMP__
+_LIT(KRebalanceName, "LB");
+const TInt KRebalancePriority=26;
+#endif
+
 TInt SupervisorThread(TAny*);
 TInt DebuggerInit();
 extern TInt InitialiseEntropyBuffers();
@@ -395,7 +400,14 @@
 		K::Fault(K::EInit3Failed);
 
 	P::StartExtensions();
+
 	M::Init4();
+
+#ifdef __SMP__
+	TheScheduler.InitLB();
+	TheScheduler.StartPeriodicBalancing();
+#endif
+
 	K::StartKernelServer();
 	return 0;
 	}
@@ -436,6 +448,18 @@
 	if (r!=KErrNone)
 		return r;
 
+#ifdef __SMP__
+	// create thread and DFC queue for load balancing
+	TScheduler& s = TheScheduler;
+	r = Kern::DfcQCreate(s.iRebalanceDfcQ, KRebalancePriority, &KRebalanceName);
+	if (r!=KErrNone)
+		return r;
+	NThread* nt = TScheduler::LBThread();
+	NKern::ThreadSetCpuAffinity(nt, KCpuAffinityAny);
+	pT = _LOFF(nt, DThread, iNThread);
+	pT->iFlags |= KThreadFlagSystemPermanent;
+#endif
+
 	// Initialise the RAM drive
 	K::InitNvRam();