97 { |
97 { |
98 if((iCountti % iPriSamplingPeriod) != 0 ) return 0; |
98 if((iCountti % iPriSamplingPeriod) != 0 ) return 0; |
99 |
99 |
100 LOGTEXT("Processing threads..."); |
100 LOGTEXT("Processing threads..."); |
101 |
101 |
102 DObjectCon& threads = *Kern::Containers()[EThread]; |
102 DObjectCon* threads = Kern::Containers()[EThread]; |
|
103 NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex |
|
104 threads->Wait(); |
103 |
105 |
104 // PRI trace variables |
106 // PRI trace variables |
105 this->iThreadCount = 0; |
107 this->iThreadCount = 0; |
106 this->iNewThreadCount = 0; |
108 this->iNewThreadCount = 0; |
107 TInt totalThreadCount = threads.Count(); |
109 TInt totalThreadCount = threads->Count(); |
108 |
110 |
109 for(TInt i=0;i<totalThreadCount;i++) |
111 for(TInt i=0;i<totalThreadCount;i++) |
110 { |
112 { |
111 DThread* t = (DThread*)(threads)[i]; |
113 //DThread* t = (DThread*)(threads)[i]; |
|
114 DObject* pO=(*threads)[i]; |
|
115 DThread* t = (DThread*)pO; |
|
116 |
112 LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t)); |
117 LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t)); |
113 |
118 |
114 if( (TAG(t) & PROFILER_THREAD_MARK) == 0) |
119 if( (TAG(t) & PROFILER_THREAD_MARK) == 0) |
115 { |
120 { |
116 LOGSTRING2("Marking thread %d",i); |
121 LOGSTRING2("Marking thread %d",i); |
130 this->threadsToSample[this->iThreadCount] = t; |
135 this->threadsToSample[this->iThreadCount] = t; |
131 this->iThreadCount++; |
136 this->iThreadCount++; |
132 LOGSTRING2("Added thread %d to threads to sample",i); |
137 LOGSTRING2("Added thread %d to threads to sample",i); |
133 } |
138 } |
134 |
139 |
|
140 threads->Signal(); |
|
141 NKern::ThreadLeaveCS(); // End of critical section |
|
142 |
135 if(this->iThreadCount > 0 || this->iNewThreadCount > 0) |
143 if(this->iThreadCount > 0 || this->iNewThreadCount > 0) |
136 { |
144 { |
137 this->iProcessing = EStartingToProcess; |
145 this->iProcessing = EStartingToProcess; |
138 |
146 |
139 // process the first sample |
147 // process the first sample |
299 this->iProcessing = ENothingToProcess; |
306 this->iProcessing = ENothingToProcess; |
300 this->sampleDescriptor.Zero(); |
307 this->sampleDescriptor.Zero(); |
301 |
308 |
302 |
309 |
303 // clear all thread tags |
310 // clear all thread tags |
|
311 NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex |
304 DObjectCon* threads = Kern::Containers()[EThread]; |
312 DObjectCon* threads = Kern::Containers()[EThread]; |
|
313 threads->Wait(); // Obtain the container mutex so the list does get changed under us |
|
314 |
305 TInt totalThreadCount = threads->Count(); |
315 TInt totalThreadCount = threads->Count(); |
306 for(TInt i=0;i<totalThreadCount;i++) |
316 for(TInt i=0;i<totalThreadCount;i++) |
307 { |
317 { |
308 DThread* t = (DThread*)(*threads)[i]; |
318 DThread* t = (DThread*)(*threads)[i]; |
309 TAG(t) = (TAG(t) & 0xfffffffd); |
319 TAG(t) = (TAG(t) & 0xfffffffd); |
310 } |
320 } |
311 } |
321 threads->Signal(); |
312 |
322 NKern::ThreadLeaveCS(); // End of critical section |
|
323 } |
|
324 |