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

Side by Side Diff: runtime/vm/os_thread_android.cc

Issue 1515553003: VM: Fix deadlock in time line recording. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ASSERT(thread_id == GetCurrentThreadId()); 204 ASSERT(thread_id == GetCurrentThreadId());
205 ASSERT(cpu_usage != NULL); 205 ASSERT(cpu_usage != NULL);
206 struct timespec ts; 206 struct timespec ts;
207 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); 207 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
208 ASSERT(r == 0); 208 ASSERT(r == 0);
209 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / 209 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) /
210 kNanosecondsPerMicrosecond; 210 kNanosecondsPerMicrosecond;
211 } 211 }
212 212
213 213
214 Mutex::Mutex() { 214 Mutex::Mutex(bool recursive) {
215 pthread_mutexattr_t attr; 215 pthread_mutexattr_t attr;
216 int result = pthread_mutexattr_init(&attr); 216 int result = pthread_mutexattr_init(&attr);
217 VALIDATE_PTHREAD_RESULT(result); 217 VALIDATE_PTHREAD_RESULT(result);
218 218
219 #if defined(DEBUG) 219 #if defined(DEBUG)
220 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 220 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
221 VALIDATE_PTHREAD_RESULT(result); 221 VALIDATE_PTHREAD_RESULT(result);
222 #endif // defined(DEBUG) 222 #endif // defined(DEBUG)
223 223
224 if (recursive) {
225 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
226 VALIDATE_PTHREAD_RESULT(result);
227 }
228
224 result = pthread_mutex_init(data_.mutex(), &attr); 229 result = pthread_mutex_init(data_.mutex(), &attr);
225 // Verify that creating a pthread_mutex succeeded. 230 // Verify that creating a pthread_mutex succeeded.
226 VALIDATE_PTHREAD_RESULT(result); 231 VALIDATE_PTHREAD_RESULT(result);
227 232
228 result = pthread_mutexattr_destroy(&attr); 233 result = pthread_mutexattr_destroy(&attr);
229 VALIDATE_PTHREAD_RESULT(result); 234 VALIDATE_PTHREAD_RESULT(result);
230 235
231 #if defined(DEBUG) 236 #if defined(DEBUG)
232 // When running with assertions enabled we do track the owner. 237 // When running with assertions enabled we do track the owner.
233 owner_ = OSThread::kInvalidThreadId; 238 owner_ = OSThread::kInvalidThreadId;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 void Monitor::NotifyAll() { 412 void Monitor::NotifyAll() {
408 // When running with assertions enabled we track the owner. 413 // When running with assertions enabled we track the owner.
409 ASSERT(IsOwnedByCurrentThread()); 414 ASSERT(IsOwnedByCurrentThread());
410 int result = pthread_cond_broadcast(data_.cond()); 415 int result = pthread_cond_broadcast(data_.cond());
411 VALIDATE_PTHREAD_RESULT(result); 416 VALIDATE_PTHREAD_RESULT(result);
412 } 417 }
413 418
414 } // namespace dart 419 } // namespace dart
415 420
416 #endif // defined(TARGET_OS_ANDROID) 421 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698