This is pretty much accurate as I did in the past.
main:
claim mutex
for each desired thread:
start child
release mutex
:
child:
claim mutex
release mutex
:
Please note that this does not actually guarantee that all threads are started before the first one starts to do something, just created the main thread.
To do this, you can use something like the following method:
main:
claim mutex
set unstarted to 0
for each desired thread:
start child
add 1 to unstarted
release mutex
:
child:
claim mutex
subtract 1 from unstarted
while unstarted > 0:
release mutex
yield // if necessary
claim mutex
release mutex
:
, , , claim subtract.
, . pthread, , .
, , - pre-v6 pthreads ( ), , , , .