CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ
Which statement about a process that calls exec() successfully is correct?
- A. It gets a new process ID but keeps its open files and heap
- B. It keeps its PID and open descriptors, but code, data, heap and stack are replaced
- C. It runs the new program as a child and resumes after it finishes
- D. It keeps its old heap so the new program can read the old data
Correct answer: B. It keeps its PID and open descriptors, but code, data, heap and stack are replaced
exec replaces the program image within the same process: the PID, parent and open descriptors survive, while text, data, heap and stack are rebuilt. It returns only on failure; creating a child is fork's job.
More Operating Systems questions
- A logical address space has 8 pages of 2 KB each, and physical memory has 32 frames. How many bits are in a logical address and in a…
- Reference string 1, 2, 3, 1, 4, 5, 1, 6, 2, 1, 3, 4 with 3 frames, initially empty. The clock (second-chance) algorithm sets a page's…
- TLB lookup 20 ns (done first), memory access 100 ns, single-level page table, TLB hit ratio 80%. In addition, 1 in every 1,000 memory…
- A bounded buffer uses semaphores empty = N, full = 0 and mutex = 1. The producer is changed to do wait(mutex) BEFORE wait(empty); the…
- Jobs A (6), B (2), C (8) and D (3) all arrive at time 0 in that order. What are the average waiting time under non-preemptive SJF and the…
- Under Linux CFS, two CPU-bound tasks share one CPU: one at nice 0 (weight 1024) and one at nice 5 (weight 335). About what share of CPU…