Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 Write a C program on Linux that creates children processes and does the following: Part I: - The parent process creates 1 child.

Problem 2

Write a C program on Linux that creates children processes and does the following:

image text in transcribed

Part I: - The parent process creates 1 child. - The child process itself creates 1 child. This will be the grandchild of the parent. - The parent process reads one number (integer) from the standard input. The parent process sends this number to the child using standard pipes. - The child multiplies the number by 2, prints it as "Child: Input X, Output X*2" and sends the result to the grandchild. - The grandchild multiplies the input number by 2, prints it as "Grandchild: Input X, Output X*2" and sends it back to the child. - The child will send the result back to the parent. - The parent prints the final result. - The parent kills all children processes, and terminates. Part II: Add a sleep(5) parameter to each process operation, so that you can track the behavior as it executes. Open two terminals. In the first terminal, run the tool *htop*. Once in htop, press *t* to sort all processes as a process tree. Resize the window so that you can see the processes properly. In the second terminal, execute your program. Find the program in htop, and take a screenshot of its hierarchy (parent/child/grandchild). Kill the child process amidst execution by pressing *k* in htop, and sending it SIGKILL to immediately terminate it. Take a screenshot of the program execution output. For Problem 2, you may need to use sleep(), kill() and fork() system calls. Refer to the ordinary pipe example in the textbook

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago