Files
sdk/runtime/vm/thread_interrupter_android.cc
T
johnmccutchan@google.com 86c55f4fde Keep list of existing isolates.
List is only updated when isolates are created / destroyed.
ThreadInterrupter now walks list of isolates.
Scheduling an isolate for interrupts is now lockless.
Setting a current isolate is now lockless.
Working on Linux, Mac, and Windows.
Assert that the isolate isn't on two threads at once.

R=asiva@google.com

Review URL: https://codereview.chromium.org//128653004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32439 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-07 17:43:21 +00:00

51 lines
1.4 KiB
C++

// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
#include "vm/signal_handler.h"
#include "vm/thread_interrupter.h"
namespace dart {
DECLARE_FLAG(bool, thread_interrupter);
DECLARE_FLAG(bool, trace_thread_interrupter);
class ThreadInterrupterAndroid : public AllStatic {
public:
static void ThreadInterruptSignalHandler(int signal, siginfo_t* info,
void* context_) {
if (signal != SIGPROF) {
return;
}
InterruptableThreadState* state = ThreadInterrupter::CurrentThreadState();
if ((state == NULL) || (state->callback == NULL)) {
// No interrupter state or callback.
return;
}
ASSERT(Thread::Compare(state->id, Thread::GetCurrentThreadId()));
}
};
void ThreadInterrupter::InterruptThread(InterruptableThreadState* state) {
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupter interrupting %p\n",
reinterpret_cast<void*>(state->id));
}
pthread_kill(state->id, SIGPROF);
}
void ThreadInterrupter::InstallSignalHandler() {
SignalHandler::Install(
ThreadInterrupterAndroid::ThreadInterruptSignalHandler);
}
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)