nthm - non-preemtive thread hierarchy manager
Nthm (pronounced like "anthem") is a C library intended for applications involving dynamic hierarchies of threads creating other threads that would be difficult or impossible to plan at compile-time. It is especially appropriate when communication between threads fits a pattern of input data being sent to each thread on creation from the one that creates it and output being sent back to the creating thread on termination. While enabling some flexibility about synchronization, the API is simpler than direct use of pthreads primitives and might let some applications to avoid explicit locking entirely.
Nthm presents a helpful abstraction in the way of a single-use, unidirectional pipe created for each thread when it is started and tethered by default as a descendent of the one starting it. Nthm keeps a record of the threads tethered above and below each one, so that user-written code can easily invoke operations like these with respect to the set of all pipes they have created:
If the threads do not operate on any shared data, then no further synchronization primitives are needed in user code. Alternatively, nthm is compatible with pthreads locks and conditions.
Nthm handles all memory management associated with maintaining the thread hierarchy, but control over flattening or otherwise reorganizing it is also available to user code through explicit tethering and untethering operations.
nthm_open, nthm_send, nthm_read, nthm_select, nthm_truncate, nthm_truncate_all, nthm_truncated, nthm_enter_scope, nthm_exit_scope, nthm_kill, nthm_kill_all, nthm_killed, nthm_untether, nthm_tether, nthm_blocked, nthm_busy, nthm_sync, nthm_strerror, pthreads (7)
Dennis Furey (milonga@delayinsensitive.com)
https://github.com/gueststar/nthm