Differentiate between process switch and mode switch in OS


A process is defined as a program in execution and an entity that represents the basic unit of work to be implemented in the system.

Process switch

It is defined as that the processor switches from one thread/process to another thread or process. It makes the contents of the CPU registers and instruction pointer to be saved.

For the new task, the registers and instruction pointer are loaded into the processor then the execution of the new process may start/resume.

The old programs will not execute further, but the state of that process is saved in memory because when the kernel decides that it is ready to execute it again. This concept is like multitasking, but in reality, only a single process can run at a time on a CPU.

A context switch occurs by hardware or software. A hardware interrupt occurs from a device like a keyboard, mouse, or system timer, which causes code to begin executing the interrupt code. Software switches occur as a result of the kernels which are performing a task switch manually.

This is the way the scheduler uses a context switch.

Features −

  • It effects the performance
  • It increases load on CPU processor.
  • Here every packet is inspected by router or switch processor.
  • On every packet load balancing is performed.
  • Easy to enable by one command.

Mode switch

The mode switch is used when the CPU changes privilege levels. The kernel works at a higher privilege than a standard user task.

In order to access user tasks that are controlled by the kernel, it is necessary for a mode switch to occur.

The currently executing process does NOT change during a mode switch. The processor uses the modes to protect the OS from misbehaving or malicious programs, as well as control concurrent access to RAM, I/O devices, etc.

A mode switch must occur for a software context switch to occur. Only the Kernel can cause a context switch.

Note − The idea of a general protection fault is that a user application has tried to do something that it isn't allowed to do, such as accessing certain parts of its address space that is not accessible to it.

Steps for Mode Switch −

  • While Executing a program we have two modes user mode and kernel mode.

  • So when a program is executed at the user level then there must be a user domain/mode.

  • And when kernel mode is responsible for program execution then there is a kernel mode.

  • Now, when a process is in badly need of a system resource then the mode switch occurs.

  • It happens with the help of either a system call interface or by using interrupts.

  • And after this kernel functions can be called from the user mode and manage the system calls.

Updated on: 01-Dec-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements