Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please explain the code first? Then, answer these questions... Thank you. 1. Let's Review the Code We Covered in Class Review the code

Can you please explain the code first? image text in transcribed
Then, answer these questions...
image text in transcribed
Thank you.
1. Let's Review the Code We Covered in Class Review the code below that we covered in class on how to create an ordinary pipe and use it to allow the parent and child process to communicate with each other. 2. Let's See If You Can Modify the Code Write a C/C++ program that creates a child process using the fork() system call. In your program, the parent process should take a positive integer value as user input via the command line interface. The parent process should then send the input value to the child process using the ordinary pipe. And then, the child process should print out the value received from the parent. 3. Let's Apply the Code to Solving a Different Problem The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: n={n/2,3n+1,ifnisevenifnisodd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1 . For example, if n=35, the sequence is 35,106,53,160,80,40,20,10,5,16,8,4,2,1. Write a C/Ct+ program that generates this sequence in the child process. In your program, the parent process should take a positive integer value as user input via the command line interface. The parent process should then send the input value to the child process using the ordinary pipe. And then, the child process should run the algorithm with the positive integer value provided by the parent process as the parameter. Make sure that the parent process invoke the wait() call to wait for the child process to complete before exiting the program. For example, when your program is started, the parent process will take the user input (a positive integer). > Please enter a positive integer. >35 And then the value 35 will be sent to the child process using the ordinary pipe. And then, the child process will run the algorithm with the integer value (35) passed by the parent process as the input and will print out the result. >35,106,53,160,80,40,20,10,5,16,8,4,2,1 > Child exit. > Parent exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

draw curved arrows to reach this solution Absolute :Br

Answered: 1 week ago