Question

In: Computer Science

What is the maximum number of processes in the system at any time using the following...

What is the maximum number of processes in the system at any time using the following code segment?

extern char mypath[];

for ( int i = 0; i < 10; i++ ) {

pid_t pid, pid_out;

unsigned char status;

if ( pid = fork() )

pid_out = wait ( &status );

else

  execl ( mypath, "child", "parameter", NULL );

}

Assume that child performs some simple computation and returns the result, that is captured in status.

Solutions

Expert Solution

-->

extern char mypath[];

for ( int i = 0; i < 10; i++ ) {

pid_t pid, pid_out;

unsigned char status;

if ( pid = fork() )

pid_out = wait ( &status );

else

  execl ( mypath, "child", "parameter", NULL );

}

--> If you see above two bold statements each time a fork() is called a new process will be created,

      then the parent process is waiting for the child to complete it's execution before running any new

      code.

--> So, maximum number of process at any time in the system is 2.


Related Solutions

Operating Systems Question 1.What is the maximum number of processes in the system at any time...
Operating Systems Question 1.What is the maximum number of processes in the system at any time using the following code segment? extern char mypath[]; for ( int i = 0; i < 10; i++ ) { pid_t pid, pid_out; unsigned char status; if ( pid = fork() ) pid_out = wait ( &status ); else execl ( mypath, "child", "parameter", NULL ); } Assume that child performs some simple computation and returns the result, that is captured in status.
Using Selection Sort on an any array of size 7, what will be the minimum/maximum number...
Using Selection Sort on an any array of size 7, what will be the minimum/maximum number of comparisons and number of exchanges? 1 for i = 1 to A.length-1 2 for j = i+1 to A.length 3 if A[j] < A[i] 4 exchange A[i] with A[j]
The following table lists the characteristics of three processes that require service in a time-sharing system...
The following table lists the characteristics of three processes that require service in a time-sharing system Assume that no time is required to choose the next process and perform a context switch. For each algorithm, show the process that is running in each time interval Process Name Arrival Time Burst/CPU Time Priority Start Time End Time Turnaround (TA) Time WTA Wait P1 2 8 1 P2 4 5 4 P3 6 2 3 p4 3 4 2 d) Preemptive Shortest...
What is the average waiting time for Processes If Operating System uses the First Come First...
What is the average waiting time for Processes If Operating System uses the First Come First Serve (FCFS) Scheduling Algorithm? (P1=5 ms, P2=10 ms, P3=15 ms) Process Order: P2, P1, P3 Select one: a. 8.3 b. 11.7 c. 10 d. 6.7
using excel and it's functions The table shows a sample of the maximum capacity (maximum number...
using excel and it's functions The table shows a sample of the maximum capacity (maximum number of spectators) of sports stadiums. The table does not include horse-racing or motor-racing stadiums. 40,000 40,000 45,050 45,500 46,249 48,134 49,133 50,071 50,096 50,466 50,832 51,100 51,500 51,900 52,000 52,132 52,200 52,530 52,692 53,864 54,000 55,000 55,000 55,000 55,000 55,000 55,000 55,082 57,000 58,008 59,680 60,000 60,000 60,492 60,580 62,380 62,872 64,035 65,000 65,050 65,647 66,000 66,161 67,428 68,349 68,976 69,372 70,107 70,585 71,594...
In digital logic circuits, what are the maximum number of inputs for the following gates: AND...
In digital logic circuits, what are the maximum number of inputs for the following gates: AND OR NOR XOR(is it 2?) XNOR (is it 2?) NAND
In an atom, what is the maximum number of electrons that can have the following quantum...
In an atom, what is the maximum number of electrons that can have the following quantum numbers? n=3, I=2, mI=-2 and n=4, I=1, mI=+1 Please explain and thank you so much!
What is the maximum number of electrons in an atom that can have the following quantum...
What is the maximum number of electrons in an atom that can have the following quantum numbers? n = 3 l = 1 18 6 3 2 1
What is the maximum number of electrons in an atom that can have the following quantum...
What is the maximum number of electrons in an atom that can have the following quantum numbers? (a) n = 3, ms = -1/2 (b) n = 6, l = 2 (c) n = 7, l = 3, ml = -1 (d) n = 2, l = 1, ml = +1, ms = +1/2
What is the maximum number of electrons in an atom that can have the following quantum...
What is the maximum number of electrons in an atom that can have the following quantum numbers? A.) n=2; ms= -1/2 B.) n=5: l=3 C.) n=4; l=3; ml= -3 D.) n=4; l=1; ml=1 Completely confused! Please explain your answer. Thanks...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT