Question: Solved with the explanation please Consider the following code #include #include void main(void) { pid_t pid; int i=0; pid = fork(); if (pid==0) pid =

Solved with the explanation please

Consider the following code

#include

#include

void main(void) {

pid_t pid; int i=0;

pid = fork();

if (pid==0)

pid = getpid();

else if (pid>0)

i=5;

else if (pid<0)

i=10;

return 0; }

What are the values of i and pid:

a)If the fork() is successful and returned in the child process:

b)If the fork() is successful and returned in the parent process:

c)If the fork() is unsuccessful:

-----------------------------------------------------

In a multiprogramming environment, consider we have the following process P1:

#

Instruction

Execution time

1

Assignment

2 ms

2

Fork ()

3 ms

3

Wait (Null)

3 ms

4

Print

2ms

Assume the following:

fork () is executed correctly.

Push time in any queue =2 ms.

Wait time in printer queue =4 ms.

Dispatch time = 1ms.

Complete the following table:

Accumulative

Time

Process

State

Executing

Instruction

Queue

Name

Execution

Time

Dispatch Time

Push

Time

Wait

Time in Q

0

Ready

Ready Q

1

1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!