Skip to content

Is wasi_thread_exit needed? #7

Description

@abrown

In a discussion yesterday with @sbc100 and @sunfishcode, we considered whether it might be necessary to add a second API call to the wasi-threads proposal to support early exit from threads. Since exception support is neither standardized nor widespread, it is impossible for a child thread to "early exit" and continue execution in the exported thread entry point, wasi_thread_start. This entry point can contain code responsible for important tasks, such as notifying joiners that the thread is complete (e.g., in wasi-libc), and possibly others such as cleaning up any TLS allocations.

One suggestion was to implement pthread_exit in wasi-libc using a new API call, wasi_thread_exit. But consider what happens when wasi_thread_exit is called: it could presumably dispose of the child thread from the host side, but it would not really have access to execute the cleanup code at the end of was_thread_start (e.g., the join notify instructions). To properly support pthread_exit it may be necessary to do more, e.g., exporting a second function from threaded modules, wasi_thread_stop.

Any additional thoughts on this?


One side issue we discussed is that traps and calls to exit in child threads take down the entire program. This eliminates a whole other set of problems and we should probably document this in the README.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions