Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program, which demonstrates interprocess communicationIPC between three processes using pipes. Your program as the parent process should create two child processes and
Write a C program, which demonstrates interprocess communicationIPC between three processes using pipes. Your program as the parent process should create two child
processes and utilize four pipes, establishing a multidirectional communication as shown in the figure below:
Note that unnecessary pipe ends must be closed to prevent improper pipe usage. Each pipe needs one write
one read end to remain open for two way communication.
The parent process should read a filename as a command line argument so that different files can be used on
each execution Each file should have an unspecified number of random integers. The parent process P
should read integers and send to BOTH child processes one by one.
P receives the integers one by one, categorizes each integer according to number of digits. For
readability, implement a function named int nrDigitsint to do this. You may assume integer
numbers in the test files be between and Count the number of integers received according
to the number of digits.
P receives the integers one by one, computes the number of prime integers received. Implement a
function named int isPrimeint to do this.
When P and P have finished their jobs, they must submit back the results they have computed back
to the parent process and terminate.
Parent process P after receiving results from P and P should print a nicely formatted output as
given in the following example and should terminate
Sample Output for input files
$ homework numbers.txt $ homework numberstxt $ homework numberstxt
Input file: numbers.txt Input file: numberstxt Input file: numberstxt
digits digits digits
digits digits digits
digits digits digits
digits digits digits
digits digits digits
Primes Primes Primes
Nonprimes Nonprimes Nonprimes
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started