Home QBASIC C Java HTML
  • More Courses
  • MCQs
  • Blog Download
  • Tools
  • Contact

    Contents

    What is Context Switching?


    The process of saving the context of one process and loading the context of another process is known as Context Switching. In simple terms, it is like loading and unloading the process from running state to ready state. 

    When does context switching happen? 

    1. When a high-priority process comes to ready state (i.e. with higher priority than the running process) 
    2. An Interrupt occurs 
    3. User and kernel mode switch (It is not necessary though) 
    4. Preemptive CPU scheduling used. 

    Context Switch vs Mode Switch 

    A mode switch occurs when CPU privilege level is changed, for example when a system call is made or a fault occurs. The kernel works in more a privileged mode than a standard user task. If a user process wants to access things that are only accessible to the kernel, a mode switch must occur. The currently executing process need not be changed during a mode switch. 

    A mode switch typically occurs for a process context switch to occur. Only the kernel can cause a context switch. 

    CPU-Bound vs I/O-Bound Processes: 

    A CPU-bound process requires more CPU time or spends more time in the running state. 

    An I/O-bound process requires more I/O time and less CPU time. An I/O-bound process spends more time in the waiting state. 


    202