Process · Operating System
11 questions · asked in 9 of 27 years (2000–2026)
MCQ 8 · MSQ 2 · NAT 11-mark 10 · 2-mark 1
2000Questions per year2026
Questions 1–5 of 11
Suppose in a multiprogramming environment, the following C program segment is executed. A process goes into I/O queue whenever an I/O related operation is performed. Assume that there will always be a context switch whenever a process requests for an I/O, and also whenever the process returns from an I/O. The number of times the process will enter the ready queue during its lifetime (not counting the time the process enters the ready queue when it is run initially) is _______. (Answer in integer)
int main()
{
int x=0,i=0;
scanf("%d",&x);
for(i=0; i<20; i++)
{
x = x + 20;
printf("%d\n",x);
}
return 0;
}
Answer: 21
Each time the process does an I/O operation, it leaves the CPU and goes to the I/O queue. When the I/O finishes, it must enter the ready queue again to wait for the CPU (context switch back).
Now count the I/O operations in this program. There is one at the start. There is also one in each of the loop iterations. So the total number of I/O operations is .
Each of these I/O completions sends the process into the ready queue once. The first entry into the ready queue, when the process starts, is not counted, and this count already leaves it out.
Answer: 21
Now count the I/O operations in this program. There is one at the start. There is also one in each of the loop iterations. So the total number of I/O operations is .
Each of these I/O completions sends the process into the ready queue once. The first entry into the ready queue, when the process starts, is not counted, and this count already leaves it out.
Answer: 21
Which of the following process state transitions is/are NOT possible?
One or more options are correct.
Answer: (B), (C)
Let us check each transition:
- Running Ready: possible (preemption, or the time slice is over).
- Waiting Running: NOT possible. When the I/O is done, the process moves to Ready. Only the scheduler can then move it to Running.
- Ready Waiting: NOT possible. A process can block (ask for I/O) only when it is running.
- Running Terminated: possible (exit).
Answer: Waiting to Running, Ready to Waiting
- Running Ready: possible (preemption, or the time slice is over).
- Waiting Running: NOT possible. When the I/O is done, the process moves to Ready. Only the scheduler can then move it to Running.
- Ready Waiting: NOT possible. A process can block (ask for I/O) only when it is running.
- Running Terminated: possible (exit).
Answer: Waiting to Running, Ready to Waiting
Consider a process P running on a CPU. Which one or more of the following events will always trigger a context switch by the OS that results in process P moving to a non-running state (e.g., ready, blocked)?
One or more options are correct.
Answer: (A), (B)
- (A) A blocking disk read makes P wait for the I/O, so the OS moves P to the blocked state and switches to another process. This always happens.
- (B) A page fault on a page in swap space means the page must be read from disk. P waits for it, so it is blocked and a context switch always happens.
- (C) A disk interrupt for another process is handled by the OS, which makes that process ready. P can keep running, so this does not always switch P out.
- (D) On a timer interrupt, P may still have time left in its slice, or the scheduler may pick P again. So P does not always leave the running state.
Answer: (A), (B)
- (B) A page fault on a page in swap space means the page must be read from disk. P waits for it, so it is blocked and a context switch always happens.
- (C) A disk interrupt for another process is handled by the OS, which makes that process ready. P can keep running, so this does not always switch P out.
- (D) On a timer interrupt, P may still have time left in its slice, or the scheduler may pick P again. So P does not always leave the running state.
Answer: (A), (B)
Consider the following statements about process state transitions for a system using preemptive scheduling.
I. A running process can move to ready state.
II. A ready process can move to running state.
III. A blocked process can move to running state.
IV. A blocked process can move to ready state.
Which of the above statements are TRUE?
I. A running process can move to ready state.
II. A ready process can move to running state.
III. A blocked process can move to running state.
IV. A blocked process can move to ready state.
Which of the above statements are TRUE?
Answer: (C)
Let us go through each statement:
- Running Ready (preemption) can happen.
- Ready Running (dispatch) can happen.
- Blocked Running cannot happen; a blocked process goes to Ready first.
- Blocked Ready (I/O done) can happen.
Answer: I, II and IV only
- Running Ready (preemption) can happen.
- Ready Running (dispatch) can happen.
- Blocked Running cannot happen; a blocked process goes to Ready first.
- Blocked Ready (I/O done) can happen.
Answer: I, II and IV only
The maximum number of processes that can be in Ready state for a computer system with n CPUs is
Answer: (D)
The number of CPUs decides only how many processes can be running at one time. The ready queue can hold any number of waiting processes.
Answer: Independent of n
Answer: Independent of n
Keep practising