0
votes

Can there be a Mode Switch without context switch with processes in Linux?

Mode Switch depicts a switch from user mode to kernel mode or the other way around. Context switch usually means when you switch to run a another process instead of the currently running one.

From what I learned, mode switch can occur only if an exception was thrown. Then the exception handler is called and decides, by looking at the exception table, what to do. But doesn't this count as a context switch? Since now the CPU performs the code of the exception handler and not the code of the process.

In addition, I know that the exception handler is necessary in order to save some needed registers for the process, and when the mode switches back to the user, the handler has to restore those registers.

So, can there really be a mode switch without context switch?

Help would be appreciated.

1

1 Answers

0
votes

Sidenotes: No, a mode switch can also occur when you want to access hardware by doing a syscall. Also, a mode switch needs to be done to save and restore processes for a context switch. You do not need to switch modes when you use userland threads.

A switch between processes running in user mode is a context switch but you typically do not refer to the kernel as a process as it handles processes. So, it seems to be an issue of terminology depending on whether or not you call your kernel a process. I would say that a mode switch can occur without a context switch.