The Gateway to Computer Science Excellence
+1 vote

Consider a process P1 that is executing on a Linux-like OS on a single core system. When P1 is executing, a disk interrupt occurs, causing P1 to go to kernel mode to service that interrupt. The interrupt delivers all the disk blocks that unblock a process P2 (which blocked earlier on the disk read). The interrupt service routine has completed execution fully, and the OS is just about to return back to the user mode of Pl. At this point in time, what are the states (ready/running/blocked) of processes P1 and P2 ? 

  1. P1 is ready and P2 is ready
  2. P1 is ready and P2 is running
  3. P1 is running and P2 is ready
  4. P1 is blocked and P2 is ready


in Operating System by Boss | 176 views
I think its 2.

Because once P1 neutralizes the interrupt, it would go to ready state. And since P2 was blocked, after resolution of interrupt it would again be running.
I also marked it as 4 but it is given as 3... shouldnt it be that P1 is blocked as the OS is just about to return the commads to the user and it hasnt returned it yet .. So how can P1 be runnning?????
Can you share the explanation?


During this process P1 was always running, but CPU was executing kernel

code, to process the interrupt. P1 is never swapped or blocked. P1 is in

running and P2 is in ready queue.


But according to question, P2 is blocked right? I m not understanding how its in ready queue.

$p_1$ gets unblocked so In ready queue.

Going to blocked state depends on the process ( unless a blocking system call ), so $p_1$ remains in the running state during I/O completion.

Ref : here

correct me if I'm wrong


The interrupt service routine has completed execution fully, and the OS is just about to return back to the user mode of P1

how P1 is running? they also mentioned that OS is about to return back to the user mode of P1.


i doubt P1 was is running state

$P_1$ never left the running queue.

 hows that possible? 

check the link you provided 

Process moved to blocked state does not imply that it is preempted. Preemption is when a process is moved back to the Ready Queue from the Running State against its will.


Among all the 5 state through which a process goes , BLOCK state is the only state where the process goes by its will .while in other it depends upon the Scheduler .. And The scheduler we have seen are care about CPU bound process , and not for I/o bound process .

so does that mean that when interrupt came P1 was not blocked at the first place?
yes I think so, just switched to kernel mode where it can't do anything, but nobody moved it to the blocking queue, ready queue and it didn't go on its own.

 can you provide some standard resource which contain detailed explanation about the same?

okay so that means if a system call or an interrupt occurs due to which the mode changes from user to kernel what ever is there in the user mode will stay there only only the mode will change ...

@Mk Utkarsh @anjali007 This could be a good read here here(page 9)

1 Answer

0 votes

Apologies for the mistake in this question.

The question mentions that  while P1 is executing, the data from the disk arrives and the interrupt gets serviced by process P1.

I think question is wrongly formulated as it should be:
1. P1 is executing
2. Disk interrupt occurs. 
3. Interrupt is serviced by the ISR after the completion of currently running instruction cycle by the CPU. 

After every instruction cycle the processor will check for interrupts to be processed if there is no interrupt is present in the system it will go for the next instruction cycle which is given by the instruction register.

If there is an interrupt present then it will trigger the interrupt handler(ISR), the handler will stop the present instruction which is processing and save its configuration in a register and load the program counter of the interrupt from a location which is given by the interrupt vector table. After processing the interrupt by the processor interrupt handler will load the instruction and its configuration from the saved register, process will start its processing where it’s left. This saving the old instruction processing configuration and loading the new interrupt configuration is also called as context switching.

Thus process P1 doesn't service the interrupt as mentioned by the question.

by Junior
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,215 questions
59,981 answers
94,636 users