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

Side by Side Diff: runtime/bin/thread_linux.cc

Issue 2613283002: Fuchsia: Use new call to get thread CPU time (Closed)
Patch Set: Delete dead code Created 3 years, 11 months 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
« no previous file with comments | « runtime/bin/thread_fuchsia.cc ('k') | runtime/bin/thread_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/thread_linux.h" 9 #include "bin/thread_linux.h"
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ASSERT(sizeof(id) == sizeof(intptr_t)); 158 ASSERT(sizeof(id) == sizeof(intptr_t));
159 return static_cast<intptr_t>(id); 159 return static_cast<intptr_t>(id);
160 } 160 }
161 161
162 162
163 bool Thread::Compare(ThreadId a, ThreadId b) { 163 bool Thread::Compare(ThreadId a, ThreadId b) {
164 return (pthread_equal(a, b) != 0); 164 return (pthread_equal(a, b) != 0);
165 } 165 }
166 166
167 167
168 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
169 ASSERT(thread_id == GetCurrentThreadId());
170 ASSERT(cpu_usage != NULL);
171 struct timespec ts;
172 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
173 ASSERT(r == 0);
174 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) /
175 kNanosecondsPerMicrosecond;
176 }
177
178
179 void Thread::InitOnce() { 168 void Thread::InitOnce() {
180 // Nothing to be done. 169 // Nothing to be done.
181 } 170 }
182 171
183 172
184 Mutex::Mutex() { 173 Mutex::Mutex() {
185 pthread_mutexattr_t attr; 174 pthread_mutexattr_t attr;
186 int result = pthread_mutexattr_init(&attr); 175 int result = pthread_mutexattr_init(&attr);
187 VALIDATE_PTHREAD_RESULT(result); 176 VALIDATE_PTHREAD_RESULT(result);
188 177
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 void Monitor::NotifyAll() { 315 void Monitor::NotifyAll() {
327 // TODO(iposva): Do we need to track lock owners? 316 // TODO(iposva): Do we need to track lock owners?
328 int result = pthread_cond_broadcast(data_.cond()); 317 int result = pthread_cond_broadcast(data_.cond());
329 VALIDATE_PTHREAD_RESULT(result); 318 VALIDATE_PTHREAD_RESULT(result);
330 } 319 }
331 320
332 } // namespace bin 321 } // namespace bin
333 } // namespace dart 322 } // namespace dart
334 323
335 #endif // defined(TARGET_OS_LINUX) 324 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/thread_fuchsia.cc ('k') | runtime/bin/thread_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698