Two-State Process Model
A process may be in one of two states: running or not running.
When the OS creates a new process, it creates a PCB for the process and enters that process in to the system in the Not Running state. The process exists, know to the OS, and is waiting for an opportunity to execute.
From time to time, the currently running process will be interrupted and the Dispatcher portion of the OS will select some other process to run. The former process goes from Running state to the Not Running state, and one of the other processed chosen by the dispatcher moves to the Running state.
- Appreciate design elements of the OS. That is each process must be represented in some way so that the OS can keep track of it.
- A structure in which processes that are not running are kept in some sort of queue, waiting their turn to execute.
- A single queue in which each entry is a pointer to the process control block of a particular process. It can also be a linked list of data blocks, in which each block represents one process…
Notice, that we can describe the behaviour of the dispatcher in terms of the queueing diagram!!
Disadvantages
Two state model is inefficient:
- because some processes are
- Not running but ready to execute
- Not running and blocked
- With a simple queue: Dispatcher must scan list to find process not-running, ready, and in queue the longest
- With multiple queues: first pick the right queue and then go round robin