Sunday 22 April 2018

isro cs question paper solution 2018 Q4 Set-A

❔ The following C program

main()
{
fork(); fork(); printf("yes");
}

If we execute this core segment, how many times string yes will be printed ?

(a) only once
(b) 2 times
(c) 4 times
(d) 8 times

Correct answer: (c) 4 times  ==>  two fork call will produce total  ((2^2) -1) = 3  new processes and the one main(initial) process  == 4 process after 2nd fork call.

lets say Starting process is P1 then after fork() call new process P2 generated,

Now, two processes are running P1 and P2. After second fork call the P1, P2 produces two new process P3 and P4. So total processes is 4. So, each process now executes the statement - "printf("yes")"

No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts