I\'m working on an exercise on the textbook \"Operating System Concepts 7th Edition\", and I\'m a bit confused about how does fork() work. From my understanding
While you cannot control which process (parent or child) gets scheduled first after the fork (in fact on SMP/multicore it might be both!) there are many ways to synchronize the two processes, having one wait until the other reaches a certain point before it performs any nontrivial operations. One classic, extremely portable method is the following:
fork, call pipe to create a pipe.fork, the process that wants to wait should close the writing end of the pipe and call read on the reading end of the pipe.read will then return 0 in the other process)