Context switching and 5 state process model


I have a high level conceptual question. What is the connection between "context switching" and the "5 state process model"?

From what I understand, context switching is a OS operation performed within the 5 state process model for cases where there is an interrupt or a process is blocked. Is this correct?

Hopefully this is clear! The concepts are obviously very complex so any additional info or even a nudge in the right direction would be helpful.

Thank you!
When the computer quits running a thread and starts running another, that's a context switch. There is a latency associated with switching threads which is sometimes relevant to a software design.

"Context switch" is a fairly generic term. It might have a more specialized meaning in terms of the five-state process model, which I've never heard of. Take this with a grain of salt.

Last edited on
5 state model is oversimplified, but you context switch when you go from running to blocked and another process is loaded to the processor and takes the 'running' state. Only one process can run in one cpu at a time (here, cpu loosly means one core, clearly modern 8 core cpu can run 8 processes at once). So any time one process stops running and another one starts running, that is a context switch.

context switches used to be rather expensive -- the cpu had to store its state on process going out (all the registers) in memory and load them back to resume when it started running again. Modern hardware has greatly reduced these costs, but it still isnt free. You don't want a process to get loaded (lets say, because its turn is up in a scheduler that juggles all the processes) and get booted right back out (because it needed some resource that isnt available right now) even on modern hardware, this burns clocks for doing nothing.
Topic archived. No new replies allowed.