WebAssembly / WebAssembly/threads

Missing docs on atomic nature of wait / notify

Open
#211 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
767
Forks
54
PR merge metrics
No merged PRs in 30d

Description

wait and notify are probably inspired by futex APIs. However, currently they seem to be underspecified in terms of atomicity. When referring to futex docs

https://man7.org/linux/man-pages/man2/futex.2.html

       loading of the futex word's value, the comparison of that value
       with the expected value, and the actual blocking will happen
       atomically and will be totally ordered with respect to concurrent
       operations performed by other threads on the same futex word.
       Thus, the futex word is used to connect the synchronization in
       user space with the implementation of blocking by the kernel.

In other words, there should be no concurrent wait/notify operations for a given address.

Here, there is no such language, only sequential ordering and "Otherwise, the wait operation begins by performing an atomic load from the given address. If the loaded value is not equal to the expected value, the operator returns 1 ("not-equal"). If the values are equal, the agent is suspended. ", this latter note not mentioning that this all has to be atomic vs other operations on the given address. An implementation (like my first prototype :P) may not preserve this atomicity if only implementing based on the wording.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the wait and notify specification wording and compare it with the linked futex documentation. Identify where the current sequential-ordering and atomic-load language is defined, then clarify the required atomic relationship among loading, comparison, blocking, and concurrent operations. Done means the specification explicitly documents the intended atomicity.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
operating-systems
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.