-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Implement precise pthread wakeups #26659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -188,6 +188,10 @@ void emscripten_condvar_signal(emscripten_condvar_t * _Nonnull condvar, uint32_t | |||||
|
|
||||||
| // If the given memory address contains value val, puts the calling thread to | ||||||
| // sleep waiting for that address to be notified. | ||||||
| // Note: Like the Linux futex syscall, this APi *does* allow spurious wakeups. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // This differs from the WebAssembly `atomic.wait` instruction itself which | ||||||
| // does *not* allow supurious wakeups and it means that most callers will want | ||||||
| // to wraps this some kind loop. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // Returns -EINVAL if addr is null. | ||||||
| int emscripten_futex_wait(volatile void/*uint32_t*/ * _Nonnull addr, uint32_t val, double maxWaitMilliseconds); | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -108,5 +108,13 @@ int pthread_cancel(pthread_t t) | |||||
| pthread_exit(PTHREAD_CANCELED); | ||||||
| return 0; | ||||||
| } | ||||||
| #ifdef __EMSCRIPTEN__ | ||||||
| // Wake the target thread in case it in emscripten_futex_wait. Normally | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // this is only done when the target is the main runtime thread and there | ||||||
| // is an event added to its system queue. | ||||||
| // However, all threads needs to be inturruped like this in the case they are | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // cancelled. | ||||||
| _emscripten_thread_notify(t); | ||||||
| #endif | ||||||
| return pthread_kill(t, SIGCANCEL); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.