Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Part I Inter-process Communication between related processes. Our goal is to use Unix system calls for creating processes and inter-process communication to solve a problem.

Part I Inter-process Communication between related processes. Our goal is to use Unix system calls for creating processes and inter-process communication to solve a problem. We will have three related processes (the Parent, Child_1, and Child_2). We will also have four pipes that will be used to provide IPC between these processes to solve a problem. The problem: The main problem we are 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.

*Stack Template Class (Stack.h) create your own template stack class, not use the STL.

Other Specifications:

Make sure to check for errors when creating each process and each pipe.

Make sure to terminate each process when it is no longer needed. Indicated when a process has ended.

Make sure the parent waits for all child processes to terminate prior to exiting or trying to print the two stacks.

Make sure to clearly show in the output when the printing of each stack begins.

Make sure to close the un-need pipes. Note that each pipe is used in a unidirectional mode, one side of the pipe is never used, and the other side should be closed as soon as it is no longer needed. (this may be at the beginning)

Make sure to test your program with larger data sets (say 100, or 1000 integers) as well, to make sure there are no unanticipated anomalies

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

=+-cach nonempty one contains a rational.

Answered: 1 week ago