Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: runtime/platform/thread_android.cc

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "platform/thread.h" 8 #include "platform/thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 VALIDATE_PTHREAD_RESULT(result); 137 VALIDATE_PTHREAD_RESULT(result);
138 } 138 }
139 139
140 140
141 intptr_t Thread::GetMaxStackSize() { 141 intptr_t Thread::GetMaxStackSize() {
142 const int kStackSize = (128 * kWordSize * KB); 142 const int kStackSize = (128 * kWordSize * KB);
143 return kStackSize; 143 return kStackSize;
144 } 144 }
145 145
146 146
147 ThreadId Thread::GetCurrentThreadId() {
148 return pthread_self();
149 }
150
151
152 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
153 ASSERT(thread_id == GetCurrentThreadId());
154 ASSERT(cpu_usage != NULL);
155 struct timespec ts;
156 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
157 ASSERT(r == 0);
158 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) /
159 kNanosecondsPerMicrosecond;
160 }
161
162
147 Mutex::Mutex() { 163 Mutex::Mutex() {
148 pthread_mutexattr_t attr; 164 pthread_mutexattr_t attr;
149 int result = pthread_mutexattr_init(&attr); 165 int result = pthread_mutexattr_init(&attr);
150 VALIDATE_PTHREAD_RESULT(result); 166 VALIDATE_PTHREAD_RESULT(result);
151 167
152 #if defined(DEBUG) 168 #if defined(DEBUG)
153 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 169 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
154 VALIDATE_PTHREAD_RESULT(result); 170 VALIDATE_PTHREAD_RESULT(result);
155 #endif // defined(DEBUG) 171 #endif // defined(DEBUG)
156 172
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 struct timespec ts; 278 struct timespec ts;
263 ComputeTimeSpec(&ts, millis); 279 ComputeTimeSpec(&ts, millis);
264 int result = pthread_cond_timedwait_monotonic( 280 int result = pthread_cond_timedwait_monotonic(
265 data_.cond(), data_.mutex(), &ts); 281 data_.cond(), data_.mutex(), &ts);
266 ASSERT((result == 0) || (result == ETIMEDOUT)); 282 ASSERT((result == 0) || (result == ETIMEDOUT));
267 if (result == ETIMEDOUT) { 283 if (result == ETIMEDOUT) {
268 retval = kTimedOut; 284 retval = kTimedOut;
269 } 285 }
270 } 286 }
271 return retval; 287 return retval;
272 } 288 }
siva 2013/11/11 03:51:54 We need a Monitor::WaitMicros implementation here
Cutch 2013/11/18 20:48:54 Done.
273 289
274 290
275 void Monitor::Notify() { 291 void Monitor::Notify() {
276 // TODO(iposva): Do we need to track lock owners? 292 // TODO(iposva): Do we need to track lock owners?
277 int result = pthread_cond_signal(data_.cond()); 293 int result = pthread_cond_signal(data_.cond());
278 VALIDATE_PTHREAD_RESULT(result); 294 VALIDATE_PTHREAD_RESULT(result);
279 } 295 }
280 296
281 297
282 void Monitor::NotifyAll() { 298 void Monitor::NotifyAll() {
283 // TODO(iposva): Do we need to track lock owners? 299 // TODO(iposva): Do we need to track lock owners?
284 int result = pthread_cond_broadcast(data_.cond()); 300 int result = pthread_cond_broadcast(data_.cond());
285 VALIDATE_PTHREAD_RESULT(result); 301 VALIDATE_PTHREAD_RESULT(result);
286 } 302 }
287 303
288 } // namespace dart 304 } // namespace dart
289 305
290 #endif // defined(TARGET_OS_ANDROID) 306 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698