Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How is a futures contract priced?

Answered: 1 week ago