Question

Does there have to be a mode switch i.e., from user mode to kernel mode in order for the action to be called a context switch?

Was it helpful?

Solution

No. Not all processors even have privilege levels.

A context switch usually means restoring an execution state from a Process Control Block. However, the notion of a context is implementation-defined. From Wikipedia:

What constitutes the context is determined by the processor and the operating system.
...
When a transition between user mode and kernel mode is required in an operating system, a context switch is not necessary; a mode transition is not by itself a context switch. However, depending on the operating system, a context switch may also take place at this time.

OTHER TIPS

context switch happens only in kernel mode. If context switching happens between two user mode processes, first cpu has to change to kernel mode, perform context switch, return back to user mode and so on. So there has to be a mode switch associated with a context switch.

Mode Switch - When a single process mode is switched from user-level to kernel-level or the other way around. It happens through the system calls. When a process call the system call, the process mode will change to kernel-mode and the kernel will start acting on behalf of the user process. And once the system call returns the process mode will change from kernel-mode to user-mode. "Mode" is a property associated with the process. So, a mode switch is switch of the mode of a single process.

Context Switch - It is when the running process current state is stored some place and a new process is chosen for running and its already stored state is loaded in the CPU registers. And now the new process starts running. This whole "context switch" procedure is done by the "Process Scheduler".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top