Question

In: Computer Science

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.

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

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.
1. What is the average waiting time for Processes If the Operating System uses the Shortest-Job-First...
1. What is the average waiting time for Processes If the Operating System uses the Shortest-Job-First (SJF) Scheduling Algorithm? (P1=5 ms, P2=10 ms, P3=15 ms) 2. How many page faults occur in the Optimum Page Replacement algorithm (OPR) with the following reference string for three-page frames?    Reference String: 4,2,1,3,2,3,4,1 3. What is the average waiting time for Processes If the Operating System uses Shortest-Job-Remaining-First (SJRF) Scheduling Algorithm? (P1=5 ms, P2=10 ms, P3=15 ms) Arrival Time ( P1=0 ms, P2=5...
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
10 parts to this one question Part 1) What is the maximum number of moles of...
10 parts to this one question Part 1) What is the maximum number of moles of H2O you could expect the reaction to produce if 4 moles of CH4 were used? Part 2 ) If only 0.5 moles of O2 were used in the reaction CH4(g) + 2 O2(g) → CO2(g) + 2 H2O(g), what is the maximum number of moles of CO2 you could expect the reaction to produce? Part 3) What is the maximum number of moles of...
. 1. In the Operating System zoo describe the 4 different types of Operating Systems and...
. 1. In the Operating System zoo describe the 4 different types of Operating Systems and describe them. 2. What is a process, when are they created and when are they terminated.
1. In the Operating System zoo describe the 4 different types of Operating Systems and describe...
1. In the Operating System zoo describe the 4 different types of Operating Systems and describe them. 2. Describe what happens when booting a computer ? 3. What are System calls. Provide 6 file and directory system calls
Why are general-purpose operating systems, such as Linux or Windows, not suitable as real-time system platforms?
Why are general-purpose operating systems, such as Linux or Windows, not suitable as real-time system platforms?
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]
Java Question here. Need to write a program that will check ANY operating system and find...
Java Question here. Need to write a program that will check ANY operating system and find out OS name and then write that info to a file in the data directory. here is where I am so far: public void writeOSName() { // TODO write the name of the operating system running this code to a file // in the data directory called os.txt // The file has to be written in the data directory of this project // Use...
Is there any overlap between the Innate and Adaptive Immune Systems? Are there any Immune system...
Is there any overlap between the Innate and Adaptive Immune Systems? Are there any Immune system components that play a role in both Innate and Adaptive?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT