Question

When a user process performs a system call, a kernel process gets invoked. Now how does this NOT result in a context switch ? Since the kernel process is different from a user process . Or Am I wrong in saying that a kernel routine (invoked by system call) and user processes belong to the same process ?

Was it helpful?

Solution

'When a user process performs a system call, a kernel process gets invoked' - not really, kernel code gets invoked. Any system call will inevitably result in a protection context change - a ring-cycle. How deep this gets depends on the call. If the call reaches ring 0, the kernel code there has access to all user and kernel threads, so the kernel code there cannot, in general, be described as a 'process' - something that has a memory-management/security context to provide protection. Typically, a ring-cycle to/from ring 0 takes 2000+ cpu-cycles, (except in German operas, where it takes three days). This overhead is absolutely required whether or not the system-call results in a thread context switch and/or process-context switch.

In those cases where the system call results in changing the set of running threads, there will be the extra overhead of a thread-context switch, especially if the change requires preemption of a thread that is running on another processor.

If any newly-running thread belongs to a different process than the preempted thread, there is the yet heavier overhead of a process-context switch.

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