CS FundamentalsHardGATE CS
How many times is each letter printed? (Every fork() succeeds.)
How many times is each letter printed? (Every fork() succeeds.)
int main() {
if (fork() == 0) {
if (fork() == 0) printf("A");
else printf("B");
} else {
fork();
printf("C");
}
}- A. A 1, B 1, C 1
- B. A 2, B 2, C 2
- C. A 1, B 1, C 4
- D. A 1, B 1, C 2
Correct answer: D. A 1, B 1, C 2
The first child forks: its child prints A, it prints B. The original forks once more and both copies print C. Totals: A 1, B 1, C 2.
More Operating Systems questions
- What is the sum of the values printed by all processes? (Every fork() succeeds.) c int main() { int n = 0; for (int i = 0; i < 3; i++) {…
- Disk cylinders 0–199, head at 50 moving TOWARD 0. Requests: 176, 79, 34, 60, 92, 11, 41, 114. What is the total head movement under SCAN…
- Disk cylinders 0–199, head at 50. Requests: 176, 79, 34, 60, 92, 11, 41, 114. Under SSTF, in what order are the requests served?
- A disk rotates at 10,000 RPM with 600 sectors per track. Seek time = 3 ms average. A request reads 300 sectors that lie on one track…
- A page fault occurs on a store instruction. Which sequence is correct for a demand-paged OS when a free frame exists?
- Which hardware support is essential for demand paging to work with instructions that can fault midway (for example a block-move…