Question: Please implement this program in C++. I am trying to use Unix system calls for creating processes and inter-process communication to solve a problem. I

Please implement this program in C++.

I am trying to use Unix system calls for creating processes and inter-process communication to solve a problem. I will have three related processes (the Parent, Child_1 and Child_2). I will also have four pipes that will be used to provide IPC between these processes to solve a problem. The problem: The main problem I am trying to solve is to generate some numbers and identify if they are prime. However, the 3 processes will share the work as follows: 1) Parent generates the numbers (e.g., numbers between 1 to 10) and sends them to Child_1 via pipe-A. 2) Child_1 reads pipe A, and sends the even numbers back to Parent using pipe B. 3) Child_1 sends the odd numbers to Child_2 for further processing, using pipe C. 4) Child_2 read pipe C and checks the (odd) numbers arriving from Child_1 to see if they are prime numbers, then uses pipe D to send the prime numbers to the Parent for final printing. The remaining odd numbers are ignored. 5) The Parent should read each pipe (pipe B) and (pipe D), immediately display each number received, and also insert the numbers in their own corresponding Template Stacks (Even_S and Prime_S). Once both child processes have terminated, the parent should pop and print each Stack.

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!