Awesome, you did good to complete todays course.

#### To continue your preparation while we publish tomorrow’s topic,

Back to Course
Gourav Jain 11 Jan 2017 12:38 am

Please, explain the 4th question of the quiz??

Rahul 11 Jan 2017 01:06 pm

how the address of parent and child process are same in question 4th

karmjit joshi 11 Jan 2017 04:21 pm

Consider the following code fragment:

if (fork() == 0)

{ a = a + 5; printf("%d,%d\n", a, &a); }

else { a = a –5; printf("%d, %d\n", a, &a); }



Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE?

 u = x + 10 and v = y u = x + 10 and v != y u + 10 = x and v = y u + 10 = x and v != y

Sumit Verma 11 Jan 2017 05:51 pm

Let's go line by line:

1.if (fork() == 0)

2. { a = a + 5; printf("%d,%d\n", a, &a); }

3. else { a = a –5; printf("%d, %d\n", a, &a); } 

Process P will execute line1. fork() will cause creation of a new child process say C1
Now Both P and C1 will start execution from the next instruction in line 1 which is the comparision of the returned value of fork() with zero.
For parent process P, this comparision is false as value returned by fork will be greater than 0(Process id of child process). So P will execute the else block.
For child process C1, Condition fork()==0 is true. So Cwill execute the if block.
Now u, v be the values printed by the parent process, and x, y be the values printed by the child process.
u= a-5, v=address of a (in parent process)
x= a+5, y=address of a (in child process)
Note one thing here: In virtual memory environment, all the processes start execution from the virtual address zero and hence both the process will have same logical address of the variable 'a' (physical address will be different).
Hence u + 10 = x and v = y is the correct option.

AMIT CHAUDHARY 11 Jan 2017 07:05 pm
karmjit joshi 12 Jan 2017 12:59 pm

When the next video will be uploaded?

Rani Raja 12 Jan 2017 01:12 pm

yes plz tell sir?

Amit Jindal 13 Jan 2017 12:40 am

Can anyone explain question 5 of quiz.

Chetna Wadhwa 14 Jan 2017 02:44 am

what about other days..after this..? haven't they been uploaded or are not accessible to me only..pl tell sum1

rahul sharma 14 Jan 2017 07:49 pm

Sir please upload next lectures and assignments . thanks a lot for the previous ones.

## Wait!

Here is a chance to join biggest community of technical Students,
Tutors with FREE learning resources and so much more.
It takes less then 60 seconds.