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 (!aOld) |
|
167 aOld = iInitialThread; |
|
168 if (!aNew) |
|
169 aNew = iInitialThread; |
|
170 if (aNew!=aOld || aNew->iTime<=0) |
|
171 { |
|
172 TUint32 tmrval = 0x7fffffffu; |
|
173 if (aNew->iTime > 0) |
|
174 { |
|
175 TUint64 x = TUint64(aNew->iTime) * TUint64(iSSX.iTimerFreqM); |
|
176 tmrval = I64HIGH(x); |
|
177 if (iSSX.iTimerFreqS) |
|
178 { |
|
179 tmrval += ((1u<<iSSX.iTimerFreqS)-1); |
|
180 tmrval >>= iSSX.iTimerFreqS; |
|
181 } |
|
182 else if (I64LOW(x) & 0x80000000u) |
|
183 ++tmrval; |
|
184 } |
|
185 iSSX.iLastTimerSet = tmrval; |
|
186 iSSX.iLocalTimerAddr->iTimerCount = tmrval; |
|
187 } |
|
188 if (aNew!=aOld) |
|
189 { |
|
190 TUint64 now = NKern::Timestamp(); |
|
191 TUint64 delta = now - iLastTimestamp.i64; |
|
192 iLastTimestamp.i64 = now; |
|
193 aOld->iLastRunTime.i64 = now; |
|
194 aOld->iTotalCpuTime.i64 += delta; |
|
195 ++iReschedCount.i64; |
|
196 ++aNew->iRunCount.i64; |
|
197 if (!aOld->iActiveState) |
|
198 aOld->iTotalActiveTime.i64 += (now - aOld->iLastActivationTime.i64); |
|
199 NSchedulable* parent = aOld->iParent; |
|
200 if (parent != aOld) |
|
201 { |
|
202 parent->iLastRunTime.i64 = now; |
|
203 if (!parent->iActiveState) |
|
204 parent->iTotalActiveTime.i64 += (now - parent->iLastActivationTime.i64); |
|
205 if (parent != aNew->iParent) |
|
206 parent->iTotalCpuTime.i64 += (now - parent->iLastStartTime.i64); |
|
207 } |
|
208 NSchedulable* np = aNew->iParent; |
|
209 if (np!=aNew && np!=parent) |
|
210 np->iLastStartTime.i64 = now; |
|
211 } |
|
212 } |
|
213 #endif |
|
214 |