When you call a system call such as fork
in process X, the kernel is said to be executing in process context. So, fork
can be said to be running in pro
schedule()
is always running in process context. The special part about it is that it can change which process context is current - but it does always have a process context. Prior to the call to context_switch()
it runs in the context of the process to be swapped out, and after it runs in the process swapped in.
The Linux kernel does not have a dedicated "swapper" task (there is an idle task, which is always runnable in case nothing else is eligible to run).