-
Notifications
You must be signed in to change notification settings - Fork 646
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
Implement async termination of blocking thread #2516
Conversation
38f769a
to
455061a
Compare
the last push passes all test cases in wasi-threads repo on macOS. |
70a66cb
to
8b14c2f
Compare
348a15d
to
1b28087
Compare
c3a7e6f
to
4877ae8
Compare
the ci failure looks unrelated
|
@eloparco Could you help review the PR? It implements feature like |
basically a port from https://github.com/yamt/garbage/blob/master/c/sig2/test.c this ported version has not been tested yet though.
for now, only update fd_read. it should be easy to apply to other methods as the necessary change is mostly mechanical.
I was assuming pthread_sigmask was an alias of sigprocmask. It's true for platforms I'm familiar with. However, after reading the descriptions in the relevant standards, I changed my mind.
Sure, I'll take a look in the next couple of days. |
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.
LGTM
Took a look. This doesn't cover user-defined functions that could have been achieved with We should be able to add these tests now, probably in a separate PR. |
user-defined functions should take care of it by itself, either using the api introduced by this PR or other approaches like #1951. i guess in many cases it's simpler than preparing for signal+longjmp.
yes. they all pass with this PR: #2516 (comment) |
@eloparco so the PR is good to you, right? Shall we merge the PR? |
LGTM |
On posix-like platforms, the rest of wasi-threads tests should pass after the recent changes including the following PRs: bytecodealliance#2516 bytecodealliance#2524 bytecodealliance#2529
Implement async termination of blocking thread (bytecodealliance#2516)
On posix-like platforms, the rest of wasi-threads tests should pass after the recent changes including the following PRs: bytecodealliance#2516 bytecodealliance#2524 bytecodealliance#2529
On posix-like platforms, the rest of wasi-threads tests should pass after the recent changes including the following PRs: bytecodealliance#2516 bytecodealliance#2524 bytecodealliance#2529
On posix-like platforms, the rest of wasi-threads tests should pass after the recent changes including the following PRs: bytecodealliance#2516 bytecodealliance#2524 bytecodealliance#2529
Send a signal whose handler is no-op to a blocking thread to wake up the blocking syscall with either EINTR equivalent or partial success. Unlike the approach taken in the `dev/interrupt_block_insn` branch (that is, signal + longjmp similarly to `OS_ENABLE_HW_BOUND_CHECK`), this PR does not use longjmp because: * longjmp from signal handler doesn't work on nuttx refer to apache/nuttx#10326 * the singal+longjmp approach may be too difficult for average programmers who might implement host functions to deal with See also bytecodealliance#1910
On posix-like platforms, the rest of wasi-threads tests should pass after the recent changes including the following PRs: bytecodealliance#2516, bytecodealliance#2524, bytecodealliance#2529, bytecodealliance#2571, bytecodealliance#2576 and bytecodealliance#2582.
send a signal whose handler is no-op to a blocking thread to wake up the blocking syscall
with either EINTR equivalent or partial success.
unlike the approach taken in the
dev/interrupt_block_insn
branch (that is, signal + longjmp similarly toOS_ENABLE_HW_BOUND_CHECK
),this PR does not use longjmp because:
todo/known issues/limitations/open questions:
make the initialization independent fromOS_ENABLE_HW_BOUND_CHECK
provide an api (or at least a build-time config) to specifiy a signal to use, instead of hardcodingSIGUSR1
.fd_read
fd_closefd_preadfd_pwritefd_readfd_writepath_opensock_acceptsock_close (?)just ENOSYSsock_connectsock_recvjust a wrapper of sock_recv_fromsock_recv_fromsock_sendjust a wrapper of sock_send_tosock_send_tosock_shutdownusually not blocksock_addr_resolvedocument/commentadd an api to terminate an instanceAdd an API to terminate instance #2538add a sampleAdd an API to terminate instance #2538readv
, it's easy to wrap it withwasm_runtime_begin_blocking_op
/wasm_runtime_end_blocking_op
. but how about something more complex, like a call which possibly blocks deep inside an external library?relevant issue: #1910