in Operating System
308 views
0 votes
0 votes

On Solving  manually  I too getting 14 as answer.

 

but on running more than 14 * are printed.

in Operating System
308 views

6 Comments

Do you have any similar previous year GATE question? (fork and number of prints)
0
0

No @Arjun  sir, I got this question from test series.

0
0
Of course, hardly any GATE aspirants follow standard resources 😉
0
0

What is the correct ansr to this qsn??

@Sachin Mittal 1

 

0
0
Since the buffer is not emptied in the given code before a call to fork, there is no answer to this question. For those wondering what should be given as answer if this question comes in GATE – GATE questions are made by IIT professors and not by GATE aspirants. But such questions can come for PSU exams and there one can follow any given logic and if your stars match you get correct mark.
1
1
edited by
Ok

bt if use CLR buffer then ans should be 14?
0
0

2 Answers

1 vote
1 vote
bcoz not possible to determine order of fork() execution it’s cpu scheduling dependent
edited by

4 Comments

That doesn't mean that. Buffers are private to a given process.
0
0
Ok means wl hv to CLR buffer before every fork() call
0
0
Yes
1
1
1 vote
1 vote

For the child processes pid=0 hence the star in the conditional operator won’t be printed

Related questions

3 votes
3 votes
1 answer
1