Skip to main content
The iodine/spoon.ih library contains Linux x86_64 helpers for process creation, thread creation, thread synchronization, and futex-based mutexes. It uses raw Linux syscalls and manages thread stacks and thread-local storage itself.
Treat this library as experimental low-level code. It creates processes and threads, allocates stacks and TLS storage, and calls Linux syscalls directly. Test it in a disposable program before using it in an application.

Process helpers

spoon(path) builds a one-element argument vector containing path and passes a null environment pointer. It does not provide a way to supply additional command-line arguments or a custom environment.
The sample assumes the executable exists. The library does not report a distinct execve failure through a documented error API.

Thread helpers

The spawned threads continue execution from the point of creation. Use food() to distinguish the main thread from threads created by spawn_spoon.
In the current implementation, a child created inside spawn_spoon(count) continues through the remaining iterations of the same loop. Counts greater than one can therefore create additional descendants rather than exactly count total threads. The tracking and synchronization code is also low-level; verify its behavior for your workload.

Mutex helpers

The mutex API uses an int as its lock word:
This is a minimal usage sketch, not a complete shared-state threading example. The mutex helpers do not provide a separate owner, timeout, or error-reporting API.

Low-level wrappers and internal state

The library also defines internal assembly wrappers for clone, atomic exchange, and futex wait/wake operations. Its _sp namespace stores a fixed table for up to 64 tracked threads and the associated stacks, TLS regions, and TID areas. The source is available in plstd/spoon.plib. This .plib source is documented as iodine/spoon.ih.