OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |