CS FundamentalsVery hardGATE CS
How many processes exist at the end, including the original? (Every fork() succeeds.)
How many processes exist at the end, including the original? (Every fork() succeeds.)
fork() && (fork() || fork()); fork();
- A. 8
- B. 16
- C. 7
- D. 6
Correct answer: A. 8
In the first line the child of the first fork short-circuits (0 && …). The parent forks again: it gets non-zero and stops, while that child evaluates the third fork. That gives 4 processes, and the last fork() doubles them to 8. 16 ignores short-circuiting; 7 counts only the new processes.
More Operating Systems questions
- f.txt does not exist at the start. Program X: fd = open("f.txt", OWRONLY|OCREAT, 0644); then fork(); the child writes "cd" and exits; the…
- Cylinders 0–299; the head is at 140 and moving toward higher numbers. Requests: 45, 210, 160, 12, 275, 98, 130, 190. Which of SSTF and…
- A disk spins at 7200 RPM, has an average seek of 6 ms and 500 sectors of 512 bytes per track. A 1 MB file is read as 256 blocks of 4 KB…
- A Unix-style inode has 12 direct pointers, one single-indirect and one double-indirect pointer; blocks are 4 KB and block pointers 4…
- Six 4 TB disks are to be combined. Which layout survives ANY two simultaneous disk failures, and what usable capacity does it give?
- A 1 MB region uses the buddy system. Requests arrive for A = 70 KB, B = 35 KB and C = 80 KB. What is the total internal fragmentation, and…