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

Side by Side Diff: src/trusted/service_runtime/linux/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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/trusted/service_runtime/nacl_app_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 #include "native_client/src/trusted/service_runtime/linux/android_compat.h" 6 #include "native_client/src/trusted/service_runtime/linux/android_compat.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <linux/futex.h> 9 #include <linux/futex.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 * Allocate register state struct if needed. This is race-free 244 * Allocate register state struct if needed. This is race-free
245 * when we are called by NaClUntrustedThreadsSuspendAll(), since 245 * when we are called by NaClUntrustedThreadsSuspendAll(), since
246 * that claims nap->threads_mu. 246 * that claims nap->threads_mu.
247 */ 247 */
248 if (save_registers && natp->suspended_registers == NULL) { 248 if (save_registers && natp->suspended_registers == NULL) {
249 natp->suspended_registers = malloc(sizeof(*natp->suspended_registers)); 249 natp->suspended_registers = malloc(sizeof(*natp->suspended_registers));
250 if (natp->suspended_registers == NULL) { 250 if (natp->suspended_registers == NULL) {
251 NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: malloc() failed\n"); 251 NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: malloc() failed\n");
252 } 252 }
253 } 253 }
254 if (pthread_kill(natp->thread.tid, NACL_THREAD_SUSPEND_SIGNAL) != 0) { 254 CHECK(natp->host_thread_is_defined);
255 if (pthread_kill(natp->host_thread.tid, NACL_THREAD_SUSPEND_SIGNAL) != 0) {
255 NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: " 256 NaClLog(LOG_FATAL, "NaClUntrustedThreadSuspend: "
256 "pthread_kill() call failed\n"); 257 "pthread_kill() call failed\n");
257 } 258 }
258 WaitForUntrustedThreadToSuspend(natp); 259 WaitForUntrustedThreadToSuspend(natp);
259 } 260 }
260 } 261 }
261 262
262 void NaClUntrustedThreadResume(struct NaClAppThread *natp) { 263 void NaClUntrustedThreadResume(struct NaClAppThread *natp) {
263 Atomic32 old_state; 264 Atomic32 old_state;
264 Atomic32 new_state; 265 Atomic32 new_state;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 NACL_APP_THREAD_SUSPENDING)); 301 NACL_APP_THREAD_SUSPENDING));
301 302
302 if (natp->fault_signal == 0) { 303 if (natp->fault_signal == 0) {
303 return 0; 304 return 0;
304 } 305 }
305 *signal = natp->fault_signal; 306 *signal = natp->fault_signal;
306 natp->fault_signal = 0; 307 natp->fault_signal = 0;
307 AtomicIncrement(&natp->nap->faulted_thread_count, -1); 308 AtomicIncrement(&natp->nap->faulted_thread_count, -1);
308 return 1; 309 return 1;
309 } 310 }
OLDNEW
« no previous file with comments | « no previous file | src/trusted/service_runtime/nacl_app_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698