0
votes

When a process in currently running in the cpu and suddenly have to wait for I\O, then the scheduler save its state (Program counter, registers..) into is PCB, and then add him to the device queue which the process wait for I\O from it.

when the process know to move from a waiting(device) queue to the ready queue? and if im doing in code Thread.Sleep(50000) does the process moving to the waiting queue?

Thanks!

1

1 Answers

0
votes

The terms are are using are all pedagogical. How this is done is entirely operating system specific.

The process of going from un-executable due to pending I/O to going to a read for execution state varies among systems.

If you're doing blocking (synchronous) I/O, there can only be one blocking I/O call pending per process (or thread). When that completes, the process should be executable. That would occur in the interrupt handler for the I/O request completion.

On some systems, completion of I/O will boost the priority of the process (or thread). In such a system, process will move ahead of other processes that are waiting because they used up their CPU quantum (as opposed to yielded the CPU voluntarily).

Many process state changes occur during timer interrupt serving. The O/S will schedule regular interrupts on the CPU. The timer interrupt handler usually looks for sleeping processes that need to be wakened, I/O requests that have been queued to be competed, and process switching.