Skip to content

Commit aab32ef

Browse files
authored
Fix references to _emscripten_main_thread_futex in comments. NFC (#18384)
1 parent c0c97c6 commit aab32ef

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

system/lib/pthread/emscripten_futex_wait.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ static int futex_wait_busy(volatile void *addr, uint32_t val, double timeout) {
2424

2525
// Register globally which address the main thread is simulating to be
2626
// waiting on. When zero, the main thread is not waiting on anything, and on
27-
// nonzero, the contents of the address pointed by __emscripten_main_thread_futex
27+
// nonzero, the contents of the address pointed by _emscripten_main_thread_futex
2828
// tell which address the main thread is simulating its wait on.
2929
// We need to be careful of recursion here: If we wait on a futex, and
3030
// then call _emscripten_yield() below, that will call code that takes the
3131
// proxying mutex - which can once more reach this code in a nested call. To
3232
// avoid interference between the two (there is just a single
33-
// __emscripten_main_thread_futex at a time), unmark ourselves before calling
33+
// _emscripten_main_thread_futex at a time), unmark ourselves before calling
3434
// the potentially-recursive call. See below for how we handle the case of our
3535
// futex being notified during the time in between when we are not set as the
36-
// value of __emscripten_main_thread_futex.
36+
// value of _emscripten_main_thread_futex.
3737
void* last_addr = a_cas_p(&_emscripten_main_thread_futex, 0, (void*)addr);
3838
// We must not have already been waiting.
3939
assert(last_addr == 0);
@@ -68,20 +68,20 @@ static int futex_wait_busy(volatile void *addr, uint32_t val, double timeout) {
6868
//
6969
// * wait on futex A
7070
// * recurse into _emscripten_yield(),
71-
// which waits on futex B. that sets the __emscripten_main_thread_futex address to
71+
// which waits on futex B. that sets the _emscripten_main_thread_futex address to
7272
// futex B, and there is no longer any mention of futex A.
73-
// * a worker is done with futex A. it checks __emscripten_main_thread_futex but does
73+
// * a worker is done with futex A. it checks _emscripten_main_thread_futex but does
7474
// not see A, so it does nothing special for the main thread.
7575
// * a worker is done with futex B. it flips mainThreadMutex from B
7676
// to 0, ending the wait on futex B.
77-
// * we return to the wait on futex A. __emscripten_main_thread_futex is 0, but that
77+
// * we return to the wait on futex A. _emscripten_main_thread_futex is 0, but that
7878
// is because of futex B being done - we can't tell from
79-
// __emscripten_main_thread_futex whether A is done or not. therefore, check the
79+
// _emscripten_main_thread_futex whether A is done or not. therefore, check the
8080
// memory value of the futex.
8181
//
8282
// That case motivates the design here. Given that, checking the memory
8383
// address is also necessary for other reasons: we unset and re-set our
84-
// address in __emscripten_main_thread_futex around calls to
84+
// address in _emscripten_main_thread_futex around calls to
8585
// _emscripten_yield(), and a worker could
8686
// attempt to wake us up right before/after such times.
8787
//

system/lib/pthread/emscripten_futex_wake.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ int emscripten_futex_wake(volatile void *addr, int count) {
2525
return 0;
2626
}
2727

28-
// See if main thread is waiting on this address? If so, wake it up by resetting its wake location to zero.
29-
// Note that this is not a fair procedure, since we always wake main thread first before any workers, so
28+
// See if main thread is waiting on this address? If so, wake it up by
29+
// resetting its wake location to zero. Note that this is not a fair
30+
// procedure, since we always wake main thread first before any workers, so
3031
// this scheme does not adhere to real queue-based waiting.
3132
int main_thread_woken = 0;
3233
if (a_cas_p(&_emscripten_main_thread_futex, (void*)addr, 0) == addr) {
3334
// The main browser thread must never try to wake itself up!
3435
assert(!emscripten_is_main_browser_thread());
35-
if (count != INT_MAX)
36-
{
36+
if (count != INT_MAX) {
3737
--count;
3838
main_thread_woken = 1;
3939
if (count <= 0) {

0 commit comments

Comments
 (0)