CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ
What does it mean that the read() system call on a terminal is 'blocking', and what state does the process enter while no input is available?
- A. read() returns −1 at once with EAGAIN and the process stays running
- B. It spins in a loop inside the kernel and stays in the running state
- C. It moves to the waiting state until input arrives, then becomes ready
- D. The process is swapped out to disk until the next key is pressed
Correct answer: C. It moves to the waiting state until input arrives, then becomes ready
A blocking call puts the process on the device's wait queue in the waiting state; the interrupt for new input moves it to the ready queue, not straight to running. Returning −1 with EAGAIN is non-blocking mode.
More Operating Systems questions
- Which statement about thrashing and the degree of multiprogramming is correct?
- Two threads acquire mutexes: T1 locks A then B; T2 locks B then A. Which change prevents deadlock while still letting both threads hold…
- A system uses demand paging with a 4 KB page, and a process allocates a fresh 1 MB zeroed buffer with mmap but touches only its first 10…
- Which statement about a system call compared with an ordinary function call is correct?
- Five batch jobs arrive together with run times 9, 6, 3, 5 and x, where x < 3. In what order should they run to minimise average turnaround…
- Statement 1: Under round robin, as the quantum shrinks towards the context-switch time, CPU efficiency approaches 50%. Statement 2: For a…