...
Mathematical-Reasoning
October 5, 2023
ISO-OSI-layers
October 5, 2023
Mathematical-Reasoning
October 5, 2023
ISO-OSI-layers
October 5, 2023

Operating-Systems

Question 6

The following C program is executed on a Unix/Linux system:

            #include <unistd.h>
            int main ()
            {
                  int i ;
                  for (i=0; i<10; i++)
                         if (i%2 == 0) fork ( ) ;
                  return 0 ;
            }

The total number of child processes created is _____.

A
26
B
33
C
31
D
28
Question 6 Explanation: 
Fork( ) statement is executed when ‘i’ is even. Thus the above code is equivalent to
#include
int main( )
{
int i;
fork( );
fork( );
fork( );
fork( );
fork( );
}
n – fork statements will have 2n-1 child.
Hence, n = 5 ⇒ We have 31 child processes.
Correct Answer: C
Question 6 Explanation: 
Fork( ) statement is executed when ‘i’ is even. Thus the above code is equivalent to
#include
int main( )
{
int i;
fork( );
fork( );
fork( );
fork( );
fork( );
}
n – fork statements will have 2n-1 child.
Hence, n = 5 ⇒ We have 31 child processes.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!