In: Computer Science
As a process executes, it changes states. Explain what are ready state, running state, and waiting state. Also, describe when a process moves between these three states
Sol:
A process is a instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently. A process may goes through different states during its execution. various events can cause a process to change its states.
A process may be in one of the following states.
Ready state
- The process is waiting to be assigned to a processor.
- Ready processes are waiting to have the processor allocated to them by the operating system so they can run. process may come into this state after start state or while running it by but interrupted by the scheduler to assign CPU to some other process.
Running state
- Instructions are being executed in this state.
- A process which is executing its instructions with the help of CPU is called in running state.
- Only one process can be in this state at a time, if there is one CPU present in system(uniprocessor).
Waiting state
A process waiting for completion of I/O or waiting for an event to occur is called in waiting state. there can be many suspended process at a time.
how a process moves between these three states
After a process is created it is admitted and it comes to the ready state. In the ready state the process is been ready to execution and its waiting to be assigned a processor so that it can begin its execution. In the ready state the scheduler dispatches it to the processor and then when it begins its execution it is in the running state, so when it is dispatched and when it receives the processor it begins its execution and when it is executing or when the instructions in the process is been executed at that moment we say that it is in the running state.