17 |
17 |
18 // NThreadBase member data |
18 // NThreadBase member data |
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
20 |
20 |
21 #include <arm.h> |
21 #include <arm.h> |
|
22 #include <arm_tmr.h> |
22 |
23 |
23 extern "C" void NewThreadTrace(NThread* a) |
24 extern "C" void NewThreadTrace(NThread* a) |
24 { |
25 { |
25 __ACQUIRE_BTRACE_LOCK(); |
26 __ACQUIRE_BTRACE_LOCK(); |
26 BTraceData.iHandler(BTRACE_HEADER_C(4,BTrace::ECpuUsage,BTrace::ENewThreadContext),0,(TUint32)a,0,0,0,0,0); |
27 BTraceData.iHandler(BTRACE_HEADER_C(4,BTrace::ECpuUsage,BTrace::ENewThreadContext),0,(TUint32)a,0,0,0,0,0); |
157 __ASSERT_WITH_MESSAGE_DEBUG(a->HeldByCurrentThread(),"The calling thread holds the mutex","NKern::FMFlash"); |
158 __ASSERT_WITH_MESSAGE_DEBUG(a->HeldByCurrentThread(),"The calling thread holds the mutex","NKern::FMFlash"); |
158 } |
159 } |
159 |
160 |
160 #endif |
161 #endif |
161 |
162 |
|
163 #if !defined(__UTT_MACHINE_CODED__) |
|
164 void TSubScheduler::UpdateThreadTimes(NThreadBase* aOld, NThreadBase* aNew) |
|
165 { |
|
166 /* If necessary update local timer frequency (DVFS) */ |
|
167 SRatioInv* pNCF = iSSX.iNewCpuFreqRI; |
|
168 if (pNCF) |
|
169 { |
|
170 iSSX.iCpuFreqRI = *pNCF; |
|
171 __e32_atomic_store_rel_ptr(&iSSX.iNewCpuFreqRI, 0); |
|
172 } |
|
173 SRatioInv* pNTF = iSSX.iNewTimerFreqRI; |
|
174 if (pNTF) |
|
175 { |
|
176 iSSX.iTimerFreqRI = *pNTF; |
|
177 __e32_atomic_store_rel_ptr(&iSSX.iNewTimerFreqRI, 0); |
|
178 } |
|
179 if (!aOld) |
|
180 aOld = iInitialThread; |
|
181 if (!aNew) |
|
182 aNew = iInitialThread; |
|
183 if (aNew!=aOld || aNew->iTime<=0 || pNTF) |
|
184 { |
|
185 TUint32 tmrval = 0x7fffffffu; |
|
186 if (aNew->iTime > 0) |
|
187 { |
|
188 tmrval = aNew->iTime; // this will have been computed based on the old timer frequency |
|
189 iSSX.iTimerFreqRI.iR.Mult(tmrval); |
|
190 } |
|
191 // iSSX.iLastTimerSet = tmrval; |
|
192 iSSX.iLocalTimerAddr->iTimerCount = tmrval; |
|
193 } |
|
194 if (aNew!=aOld) |
|
195 { |
|
196 TUint64 now = NKern::Timestamp(); |
|
197 TUint64 delta = now - iLastTimestamp.i64; |
|
198 iLastTimestamp.i64 = now; |
|
199 aOld->iLastRunTime.i64 = now; |
|
200 aOld->iTotalCpuTime.i64 += delta; |
|
201 ++iReschedCount.i64; |
|
202 ++aNew->iRunCount.i64; |
|
203 if (!aOld->iActiveState) |
|
204 aOld->iTotalActiveTime.i64 += (now - aOld->iLastActivationTime.i64); |
|
205 NSchedulable* parent = aOld->iParent; |
|
206 if (parent != aOld) |
|
207 { |
|
208 parent->iLastRunTime.i64 = now; |
|
209 if (!parent->iActiveState) |
|
210 parent->iTotalActiveTime.i64 += (now - parent->iLastActivationTime.i64); |
|
211 if (parent != aNew->iParent) |
|
212 parent->iTotalCpuTime.i64 += (now - parent->iLastStartTime.i64); |
|
213 } |
|
214 NSchedulable* np = aNew->iParent; |
|
215 if (np!=aNew && np!=parent) |
|
216 np->iLastStartTime.i64 = now; |
|
217 } |
|
218 } |
|
219 #endif |
|
220 |