Write a C program using fork() alone to mimic the below below observations. Consider the following statements: S2 S1 z 1 S3 c a b; S3 S 4 d C-1; S4 The corresponding Precedence graph is as shown above Solution In the above description we are having statements execute parallely. This is because, the system may have multiple CPUs or floating point units which compute at the same time as CPU. Problem is some statements must be completed before others begun. And to construct these type of statements we are using fork(). Fork() look like fork label and splits process into two, which is starting at the label and other is which is falling through. fork L; a:=x+y; ... L: :b=z+1; Fork() system call is used for creating Processes. It returns process ID. It creates new process which is the child process of the caller. Along with Fork() we can use parallel construct Join(). Join() merges processes and has count label. Count will zero if there is a branch at label. count :=count - 1; if count =0 then goto label; Now for above precedence graph, code will be as below: count=2; fork dopar; a:= x+y; goto donepar; dopar: b:=z+1 donepar: join count, cont; quit; cont: c:=a+b; d:=c-1; Strengths using fork() system call is, simple, powerful, easy to derive from precedence graphs..