|
My goal is just to spur a discussion, since cooperative tasks and preemptible threads do have a lot of common points of functionality. I'm not proposing anything concrete here, just noticing some similarities that might inform both this and WASI.
Here's a table describing what all functionality various things have:
| Operation |
Linux processes |
Erlang processes |
POSIX Threads |
C# Tasks |
Tokio tasks |
Go's goroutines |
| Spawn |
clone(...) |
spawn and friends |
pthread_create |
Task.run(...) |
tokio::spawn(async { ... }) |
go ... |
| Yield |
sched_yield() |
yield() |
sched_yield() |
await Task.Yield() |
tokio::task::yield_now() |
| Return |
return from main |
return from function |
return from function |
return from delegate |
return from task |
| Exit |
_exit(code) |
exit(Reason) |
pthread_exit(retval) |
runtime.Goexit() |
| Suspend |
kill(pid, SIGSTOP) |
suspend_process |
indirectly via channel receive |
indirectly via tokio::sync::oneshot |
indirectly via channel receive |
| Resume |
kill(pid, SIGCONT) |
resume_process |
indirectly via channel send |
indirectly via tokio::sync::oneshot |
indirectly via channel send |
| Terminate |
kill(pid, SIGTERM) |
exit(Pid, normal) |
pthread_cancel(tid) |
indirectly via cancellation tokens |
indirectly via channels |
| Kill |
kill(pid, SIGKILL) |
exit(Pid, kill) |
join_handle.abort() |
| Wait |
wait(pid, &status, 0) |
monitor(process, Pid) (indirectly) |
pthread_join(tid, &retval) |
await, task.Wait() |
join_handle.await |
indirectly via channels |
|