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

Unified Diff: src/trusted/service_runtime/win/thread_suspension.c

Issue 11543028: Allow creating a NaClAppThread without creating a new host OS thread (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Review: Add NACL_WUR Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/service_runtime/thread_suspension_test.cc ('k') | tests/minnacl/minimal_test_host.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/win/thread_suspension.c
diff --git a/src/trusted/service_runtime/win/thread_suspension.c b/src/trusted/service_runtime/win/thread_suspension.c
index eccb898a3e1706811214fbd8bbe038ec575d8b76..648075edddce737d536d3cdf3ca0f23e4134843c 100644
--- a/src/trusted/service_runtime/win/thread_suspension.c
+++ b/src/trusted/service_runtime/win/thread_suspension.c
@@ -17,6 +17,11 @@ struct NaClAppThreadSuspendedRegisters {
CONTEXT context;
};
+static HANDLE GetHostThreadHandle(struct NaClAppThread *natp) {
+ CHECK(natp->host_thread_is_defined);
+ return natp->host_thread.tid;
+}
+
void NaClAppThreadSetSuspendState(struct NaClAppThread *natp,
enum NaClSuspendState old_state,
enum NaClSuspendState new_state) {
@@ -45,8 +50,9 @@ void NaClUntrustedThreadSuspend(struct NaClAppThread *natp,
if (natp->suspend_state == NACL_APP_THREAD_UNTRUSTED) {
CONTEXT temp_context;
CONTEXT *context;
+ HANDLE thread_handle = GetHostThreadHandle(natp);
- if (SuspendThread(natp->thread.tid) == (DWORD) -1) {
+ if (SuspendThread(thread_handle) == (DWORD) -1) {
NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: "
"SuspendThread() call failed\n");
}
@@ -79,7 +85,7 @@ void NaClUntrustedThreadSuspend(struct NaClAppThread *natp,
context->ContextFlags = CONTEXT_CONTROL;
}
- if (!GetThreadContext(natp->thread.tid, context)) {
+ if (!GetThreadContext(thread_handle, context)) {
NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: "
"GetThreadContext() failed\n");
}
@@ -92,7 +98,7 @@ void NaClUntrustedThreadSuspend(struct NaClAppThread *natp,
void NaClUntrustedThreadResume(struct NaClAppThread *natp) {
if (natp->suspend_state == NACL_APP_THREAD_UNTRUSTED) {
- if (ResumeThread(natp->thread.tid) == (DWORD) -1) {
+ if (ResumeThread(GetHostThreadHandle(natp)) == (DWORD) -1) {
NaClLog(LOG_FATAL, "NaClUntrustedThreadResume: "
"ResumeThread() call failed\n");
}
@@ -108,7 +114,7 @@ void NaClAppThreadGetSuspendedRegistersInternal(
void NaClAppThreadSetSuspendedRegistersInternal(
struct NaClAppThread *natp, const struct NaClSignalContext *regs) {
NaClSignalContextToHandler(natp->suspended_registers, regs);
- if (!SetThreadContext(natp->thread.tid,
+ if (!SetThreadContext(GetHostThreadHandle(natp),
&natp->suspended_registers->context)) {
NaClLog(LOG_FATAL, "NaClAppThreadSetSuspendedRegistersInternal: "
"SetThreadContext() failed\n");
@@ -128,7 +134,7 @@ int NaClAppThreadUnblockIfFaulted(struct NaClAppThread *natp, int *signal) {
* Decrement Windows' suspension count for the thread. This undoes
* the effect of debug_exception_handler.c's SuspendThread() call.
*/
- previous_suspend_count = ResumeThread(natp->thread.tid);
+ previous_suspend_count = ResumeThread(GetHostThreadHandle(natp));
if (previous_suspend_count == (DWORD) -1) {
NaClLog(LOG_FATAL, "NaClAppThreadUnblockIfFaulted: "
"ResumeThread() call failed\n");
« no previous file with comments | « src/trusted/service_runtime/thread_suspension_test.cc ('k') | tests/minnacl/minimal_test_host.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698