Issue
A lot of different sources present different state-scheme of thread states : with only 3 states(blocking , runnable and exuting ) , with 7 or 12 states (e.g. blocking suspended , new and other) . I want to figure out , what the modern approach to classify these states .
Please , explain the main states and it's meanings.
Solution
The number of possible states can be as many as the designers need for their purposes. The names of the states are whatever names the designers choose. Like you said, it's different in different operating systems. Typically there will be at least:
- A state with a name like, "running," which means that the thread actually is running on some CPU.
- A state with a name like. "runnable," which means that the only reason why the thread is not running on some CPU is, that there is no CPU available at that moment.
- One or more states with names suggesting that something needs to happen before the thread can become "runnable." There could be as many different named states as there are different reasons why a thread is not allowed to run.
For example;
- Waiting for some other thread to unlock a mutex,
- Waiting for some other thread to signal a condition variable,
- Waiting for some I/O operation to complete,
- Waiting for some definite amount of time to pass,
- Waiting for some OS-specific, inter-process communication,
- "Suspended" by some other thread, and waiting to be "resumed,"
- ...
The designers of one OS might choose to roll all of those together into a single state, and call it "blocked." The designers of some other OS might decide that each one of those deserves its own name. They could even break it down further. E.g., "waiting for I/O" could be broken into;
- Waiting for file I/O,
- Waiting for network I/O,
- Waiting for local keyboard/mouse input,
- Waiting for a memory page to be faulted in,
- ...
Answered By - Solomon Slow Answer Checked By - Robin (WPSolving Admin)