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

Side by Side Diff: documentation/nonsfi_mode_async_signals.txt

Issue 1293793009: Reland "Non-SFI mode: Add Linux asynchronous signal support" (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Fixed races on thread termination and removed the broken FP-restoration code Created 5 years, 4 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
OLDNEW
(Empty)
1 Async signals support in Non-SFI mode
2 =====================================
3
4 Issue: https://code.google.com/p/nativeclient/issues/detail?id=4065
5
6 This provides a way to asynchronously interrupt another thread in the same
7 process, in a similar fashion to POSIX signals. Signal support is limited to
8 Non-SFI mode (see nacl_irt_async_signal_handling in src/untrusted/irt/irt.h).
9
10 Async signals have several differences from POSIX signals:
11
12 * Synchronous signals (from hardware exceptions) are separate and their behavior
13 is not changed. Furthermore, synchronous signals cannot be handled with this
14 interface.
15 * There is a single type of signal, and only a single, global async signal
16 handler is supported. This means that there is no support for POSIX signal
17 numbers.
18 * There is no way to block signals, not even when the signal handler is running.
19 * There is no equivalent to sigaltstack(), so the signal handler always runs on
20 the same stack as the thread.
21 * We don't provide libc wrapper functions for this interface in libnacl at the
22 moment. If full POSIX support is needed, it can be implemented in user code,
23 on top of the IRT interfaces provided.
24 * NaCl signals are not intended to abort any in-process operations (such as
25 syscalls, IRT calls or PPAPI calls) and they will restart once the signal
26 handler returns. There are two exceptions that will be interrupted and do
27 fail with EINTR:
28 * futex_wait_abs() with a non-NULL timeout
29 * nanosleep()
30
31 Similar to POSIX signals, NaCl signals are delivered the next time the thread is
32 scheduled to run but before giving the process control of execution. This also
33 means that if several signals are sent to a thread before it is scheduled to
34 run, a single async signal will be delivered, and the signal handler will be run
35 just once. That also means that the signal handler can run at any point during
36 the program execution, so the signal handler must be written with care to avoid
37 doing unsafe operations, such as acquiring mutexes that may be held by the
38 interrupted thread. Invoking any unsafe operation from within a signal handler
39 is undefined. NaCl only guarantees that the following IRT interfaces are
40 async-signal-safe and can be called from within the signal handler:
41
42 * tls_get()
43 * futex_wait_abs()
44 * futex_wake()
45 * send_async_signal()
46
47 In order to deliver signals to the correct thread, a new version of the
48 nacl_irt_thread IRT functions has been introduced which will assign an opaque
49 thread identifier to each new thread and will populate it into the |child_tid|
50 parameter. Since the initial thread is not created using nacl_irt_thread, the
51 constant NACL_IRT_MAIN_THREAD_TID can be used to refer to it. This thread
52 identifier can be used as a parameter to send_async_signal(). Providing a
53 thread identifier that is not NACL_IRT_MAIN_THREAD_TID, was not obtained from
54 thread_create, or belonged to a thread that has already terminated will produce
Mark Seaborn 2015/08/20 15:44:30 Instead of saying "will produce undefined behavior
Luis Héctor Chávez 2015/08/20 16:13:49 Done, and reworded the case where the ID is invali
55 undefined behavior.
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/nonsfi/irt/irt.gyp » ('j') | src/untrusted/irt/irt.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698