3 ms·
Yeah... It's been years since I thought about this, but: for linux you basically have two options: fork() and pthreads. Fork creates a new process and IPC be
by dnautics 12y ago
Yeah... It's been years since I thought about this, but: for linux you basically have two options: fork() and pthreads. Fork creates a new process and IPC between the parent and daughter processes can be cumbersome - and it's not a terribly good system since if you're spawning a process to do a different task, the default state contains overhead of the old task. Pthreads gives you shared memory (and simple mutexes to protect critical data) but that's about it.
Beos' app model discouraged the use of fork() - but you could if you wanted to - and instead had a pthreads-like kernel level support for threads with some very nice C classes that handle message-passing and the like; interthread communication was baked in in too so you could have strong IPC without pipes. BeOS also came with a hybrid spinlock-semaphore mutex called the 'benaphore'.
There were some very excellent C++ wrappers for all of these too, the BLooper class was a by-default message handling loop (for example).
Finally, the threading model was pretty cool, it was a logarithmic stochastic time allocator with a range of "hard priorities" that would give you RT control (but could also freeze your machine if you had an infinite loop). Unfortunately the kernel had a tendency to thrash threads between CPUs in a multi-cpu setup. I think this was fixed in Haiku.