Cooperative concurrency
mu ships with deterministic, cooperative tasks and channels.
Tasks and channels
fn worker(out, n) {
i := 1
total := 0
while i <= n {
total = total + i
i = i + 1
}
send(out, total)
}
ch := chan()
task(worker, ch, 10)
print(recv(ch))
Semantics
- Tasks yield at blocking operations (
send,recv,wait,sleep, I/O). - FIFO scheduling keeps execution deterministic.
- Channels support buffered and unbuffered modes.
pollandpushprovide non-blocking operations — andpoll(ch, timeout_ms)is the scheduler’s timed receive: it parks until a value arrives or the deadline passes, answering[ok, value]either way.- When main returns, the program ends: every other task — runnable, sleeping, or parked in I/O — is abandoned, exactly as Go leaves its goroutines.
Backend support
Concurrency is part of the runtime contract, not a Go-host-only experiment. It runs through the Go bytecode VM, the Go native backend, the self-hosted VM, and the self-hosted native backend on that backend’s supported targets.
The native runtimes also park tasks around blocking system calls such as
read, write, accept, connect, recvfrom, sendto, and nanosleep, so
one blocked task does not stop the whole process.
See docs/Specification.md for the full contract.
Next steps
- Learn the execution model in the runtime guide.
- Explore core syntax in the language tour.
- See the standard library for task and channel helpers.