Question: You will write a program that uses fork) to create two child processes that will play rounds of RPS. The child processes will wait until

 You will write a program that uses fork) to create two
child processes that will play rounds of RPS. The child processes will

You will write a program that uses fork) to create two child processes that will play rounds of RPS. The child processes will wait until the parent "signals" (Note: you don't actually need to use UNIX signals to do this, you can use your chosen IPC methods) that they should choose their next "throw." The children should repeat this wait-throw-wait proce ss until they are signaled to exit. The parent process should output each child's process id and, for each round, output each child's throw" and the result of the round. After the tournament is over, the parent should output the aggregate re sults. For example S/rps1 3 Child 1 PID: 113 Child 2 PID: 114 Beginning 3 Rounds... Fight! Round 1 Child 1 throws Scissors Child 2 throws Rock! Child 2 Wins! Round 2: Child 1 throws Paper Child 2 throws Scissors Child 2 Wins Round 3 Child 1 throws Paper! Child 2 throws Rock Child 1 Wins! Results: Child 1: 1 Child 2: 2 Child 2 Wins

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!