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.
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?
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?
Answer the following questions about computer operating systems: Consider the following set of processes, with the...
Answer the following questions about computer operating systems: Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process Burst Time Priority P1 10 3 P2 1 1 P3 2 3 P4 1 4 P5 5 2 The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0 Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, nonpreemptive priority (lower number implies...
What is an operating system? What are its functions? What are the types of operating system?
What is an operating system? What are its functions? What are the types of operating system?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT