Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that we have Parent.c as follows. It is compiled and linked to generate Parent executable. L1: #include L2: #define NULL 0 L3: int main

Suppose that we have Parent.c as follows. It is compiled and linked to generate Parent executable.

L1: #include

L2: #define NULL 0

L3: int main (void)

L4: {

L5: if (fork() == 0){

L6: //execve("Child",NULL,NULL);

L7: printf("I am child process with PID: %d ", getpid());

L8: // exit(0);

L9: } else {

L10: printf("Process[%d]: in execution ... ", getppid());

L11: sleep(5);

L12: if(wait(NULL) > 0)

L13: printf("Process[%d]: ", getpid());

L14: printf("Process[%d]: ... ", getppid());

L15: }

L16: printf("HHHH:%d ", getpid());

L17: }

L1 denotes Line 1, L2 denotes L2, etc. If we run the Parent program:

a: How many times will L16 execute? That is, how many lines of HHHH will be printed? Please briefly explain.

b: What information will Line 13 print out?

c: Which process P is the parent for the Parent process? In the above code, which lines will print out the process ID for process P?

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions