Search code examples
cmultiprocessingforkclonewait

C fork - how to wait for all children before starting workload?


I am trying to get fork() to create multiple processes all of which do the same work. I need all of them to get created first, and then at the same time start doing work. That is, I want all of the processes to wait for all of the other ones to get created, and once they are all ready, start doing the work at the same exact time.

Is this possible? Thanks.


Solution

  • The simplest approach would be simply using signals, do note however that there is no way to actually guarantee that the processes will indeed run in parallel.

    That's for the OS to decide.