Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 send a notification to another thread in | |
|
Mark Seaborn
2015/08/12 01:43:06
How about "asynchronously interrupt another thread
Luis Héctor Chávez
2015/08/12 22:14:25
Done.
| |
| 7 the same process, in a similar fashion to POSIX signals. Signal support is | |
| 8 limited to Non-SFI mode. | |
| 9 | |
|
Mark Seaborn
2015/08/12 01:43:06
Can you add "see nacl_irt_async_signal_handling in
Luis Héctor Chávez
2015/08/12 22:14:25
Done.
| |
| 10 Async signals have several differences with POSIX signals: | |
|
Mark Seaborn
2015/08/12 01:43:06
Nit: "differences from"?
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 11 | |
| 12 * Hardware/synchonous signals are separate and their behavior is not changed. | |
|
Mark Seaborn
2015/08/12 01:43:06
"synchronous"
Maybe say "Synchronous signals (fro
Luis Héctor Chávez
2015/08/12 22:14:25
Done.
| |
| 13 Furthermore, synchronous signals cannot be handled with this interface. | |
| 14 * There is a single type of signal, and only a single, global async signal | |
| 15 handler is supported. This means that there is no support for POSIX signal | |
| 16 numbers. | |
| 17 * There is no way to block signals, not even when the signal handler is running. | |
| 18 This means that the signal handler must be reentrant. | |
|
Mark Seaborn
2015/08/12 01:43:06
This sentence is not necessarily true. User code
Luis Héctor Chávez
2015/08/12 22:14:25
Removed
| |
| 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 userspace, | |
|
Mark Seaborn
2015/08/12 01:43:06
Nit: "user space" -> "user code"
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 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). Some syscalls may be interrupted and may | |
| 26 return EINTR, but users must not assume this will always be true. | |
|
Mark Seaborn
2015/08/12 01:43:06
No, the intent is you *shouldn't* get EINTR.
Are
Luis Héctor Chávez
2015/08/12 22:14:26
Yes: futex_wait (with non-null timeout) and nanosl
| |
| 27 | |
| 28 Similar to POSIX signals, NaCl signals are delivered the next time the thread is | |
| 29 scheduled to run but before giving the process control of execution. This also | |
| 30 means that if several signals are sent to a thread before it is scheduled to | |
| 31 run, a single async signal will be delivered, and the signal handler will be run | |
| 32 just once. That also means that the signal handler can run at any point during | |
| 33 the program execution, so the signal handler must be written with care to avoid | |
| 34 doing unsafe operations, such as acquiring mutexes that may be held by the | |
| 35 interrupted thread. Invoking any unsafe operation from within a signal handler | |
| 36 is undefined. NaCl only guarantees that the following functions are | |
|
Mark Seaborn
2015/08/12 01:43:06
"functions" -> "IRT interfaces"
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 37 async-signal-safe and can be called from within the signal handler: | |
| 38 | |
| 39 * tls_get | |
|
Mark Seaborn
2015/08/12 01:43:06
Can you add "()" to these?
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 40 * futex_wait_abs | |
| 41 * futex_wake | |
| 42 * send_async_signal | |
| 43 | |
| 44 In order to deliver signals to the correct thread, a new version of the | |
| 45 nacl_irt_thread IRT functions has been introduced which will assign an opaque | |
| 46 thread identifier to each new thread and will populate it into the |child_tid| | |
| 47 parameter. Since the main thread is not created using nacl_irt_thread, the | |
|
Mark Seaborn
2015/08/12 01:43:06
Nit: "main thread" -> "initial thread"
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 48 constant NACL_IRT_MAIN_THREAD_TID can be used to refer to it. This thread | |
| 49 identifier can be used as a parameter to send_async_signal. Providing a thread | |
|
Mark Seaborn
2015/08/12 01:43:06
Nit: Add "()" to "send_async_signal()"
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
| |
| 50 identifier that is not NACL_IRT_MAIN_THREAD_TID, was not obtained from | |
| 51 thread_create, or belonged to a thread that has already terminated will produce | |
| 52 undefined behavior. | |
| OLD | NEW |