chapter
    Processes, Threads, System Calls and Context Switching Notes for GATE CS

    Processes, Threads, System Calls and Context Switching notes for GATE CS: 53 study cards covering concepts, formulas, shortcuts and exam traps, plus solved pr

    processes threads system calls and context switching notes

    Chapter Roadmap: Processes, Threads, System Calls and Context Switching

    Chapter Journey: 4 Topics, One Clear Path

    This chapter builds your understanding of how the operating system manages execution. Here is what you will master:

    Topic 1: Process States, Ready Queues and Context Switching (Current)
    • Understand the lifecycle of a process: new, ready, running, blocked, terminated
    • Learn how the OS maintains ready queues and decides which process runs next
    • Master context switching: what gets saved, what gets loaded, and the overhead involved
    • Foundation for everything else in this chapter
    Topic 2: Threads and Thread Context
    • Threads as lightweight units of execution within a process
    • What threads share versus what they keep private
    • Thread context switching versus process context switching
    Topic 3: System Calls and User-Kernel Mode Transitions
    • The boundary between user mode and kernel mode
    • How programs request OS services through system calls
    • The mechanism of mode transition and its triggers
    Topic 4: Process Creation using Fork and Wait
    • The fork system call: creating child processes
    • Understanding parent-child relationships
    • The wait system call: synchronization between processes
    What You Will Achieve:

    By the end of this chapter, you will be able to trace process state transitions, calculate context switch overhead, distinguish between process and thread behavior, predict the number of processes created by fork loops, and identify which operations trigger user-to-kernel mode transitions.

    What is a Process? The Unit of Execution

    Process = Program in Execution

    A process is a program in execution. It is the fundamental unit of work in a modern operating system.

    Program versus Process

    AspectProgramProcess
    NaturePassive entityActive entity
    StorageStored on diskLoaded in memory
    AnalogyRecipe in a cookbookThe act of cooking
    LifetimePermanent fileTemporary execution

    What Makes Up a Process?

    A process in memory contains:

    1. Text section: The compiled program code
    2. Program counter: Points to the next instruction to execute
    3. Stack: Temporary data, function parameters, return addresses, local variables
    4. Data section: Global variables
    5. Heap: Dynamically allocated memory (grows during execution)

    Process Control Block (PCB)

    The operating system tracks each process using a Process Control Block (PCB). Think of it as the process identity card. It contains:

    • Process state: current state (new, ready, running, blocked, terminated)
    • Program counter: address of next instruction
    • CPU registers: contents of all registers when process was last running
    • CPU scheduling information: priority, pointers to scheduling queues
    • Memory management information: base and limit registers, page tables
    • Accounting information: CPU time used, time limits, process number
    • I/O status information: list of I/O devices allocated, open files

    The PCB is the key data structure that allows the operating system to support multiple processes simultaneously.

    The Five-State Process Model

    Five States of a Process

    Every process transitions through these five states during its lifetime:

    1. New
    The process is being created. PCB is being allocated and initialized. Memory is being allocated. Short-lived transitional state.
    2. Ready
    Process is loaded in memory and waiting for CPU assignment. All resources except CPU are available. Multiple processes can be in Ready state simultaneously. Organized in ready queues.
    3. Running
    Instructions are being executed. Only ONE process can be Running on a single CPU at any instant. Process has been assigned the CPU by the scheduler. Continues until it terminates, requests I/O, is preempted, or an event occurs.
    4. Blocked (Waiting)
    Process cannot continue until some external event occurs. Waiting for I/O completion, signal, message, or resource. Multiple processes can be Blocked simultaneously. Organized in device queues or event queues.
    5. Terminated (Exit)
    Process has finished execution. OS deallocates resources and removes PCB. Short-lived transitional state before complete removal.

    Key Observations

    • A process is active only in Running state
    • A process is eligible to run in Ready state
    • A process is ineligible to run in Blocked state (even if CPU is free)
    • The transition from Blocked to Ready happens when the awaited event occurs
    • The transition from Ready to Running happens through CPU scheduling

    50 more cards in this chapter

    Free preview ends here

    Login to view the complete notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Processes, Threads, System Calls and Context Switching Notes for GATE CS

    Processes, Threads, System Calls and Context Switching notes for GATE CS: 53 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Chapter Roadmap: Processes, Threads, System Calls and Context Switching

    Chapter Journey: 4 Topics, One Clear Path

    This chapter builds your understanding of how the operating system manages execution. Here is what you will master:

    Topic 1: Process States, Ready Queues and Context Switching (Current)
    • Understand the lifecycle of a process: new, ready, running, blocked, terminated
    • Learn how the OS maintains ready queues and decides which process runs next
    • Master context switching: what gets saved, what gets loaded, and the overhead involved
    • Foundation for everything else in this chapter
    Topic 2: Threads and Thread Context
    • Threads as lightweight units of execution within a process
    • What threads share versus what they keep private
    • Thread context switching versus process context switching
    Topic 3: System Calls and User-Kernel Mode Transitions
    • The boundary between user mode and kernel mode
    • How programs request OS services through system calls
    • The mechanism of mode transition and its triggers
    Topic 4: Process Creation using Fork and Wait
    • The fork system call: creating child processes
    • Understanding parent-child relationships
    • The wait system call: synchronization between processes
    What You Will Achieve:

    By the end of this chapter, you will be able to trace process state transitions, calculate context switch overhead, distinguish between process and thread behavior, predict the number of processes created by fork loops, and identify which operations trigger user-to-kernel mode transitions.

    What is a Process? The Unit of Execution

    Process = Program in Execution

    A process is a program in execution. It is the fundamental unit of work in a modern operating system.

    Program versus Process

    AspectProgramProcess
    NaturePassive entityActive entity
    StorageStored on diskLoaded in memory
    AnalogyRecipe in a cookbookThe act of cooking
    LifetimePermanent fileTemporary execution

    What Makes Up a Process?

    A process in memory contains:

    1. Text section: The compiled program code
    2. Program counter: Points to the next instruction to execute
    3. Stack: Temporary data, function parameters, return addresses, local variables
    4. Data section: Global variables
    5. Heap: Dynamically allocated memory (grows during execution)

    Process Control Block (PCB)

    The operating system tracks each process using a Process Control Block (PCB). Think of it as the process identity card. It contains:

    • Process state: current state (new, ready, running, blocked, terminated)
    • Program counter: address of next instruction
    • CPU registers: contents of all registers when process was last running
    • CPU scheduling information: priority, pointers to scheduling queues
    • Memory management information: base and limit registers, page tables
    • Accounting information: CPU time used, time limits, process number
    • I/O status information: list of I/O devices allocated, open files

    The PCB is the key data structure that allows the operating system to support multiple processes simultaneously.

    The Five-State Process Model

    Five States of a Process

    Every process transitions through these five states during its lifetime:

    1. New
    The process is being created. PCB is being allocated and initialized. Memory is being allocated. Short-lived transitional state.
    2. Ready
    Process is loaded in memory and waiting for CPU assignment. All resources except CPU are available. Multiple processes can be in Ready state simultaneously. Organized in ready queues.
    3. Running
    Instructions are being executed. Only ONE process can be Running on a single CPU at any instant. Process has been assigned the CPU by the scheduler. Continues until it terminates, requests I/O, is preempted, or an event occurs.
    4. Blocked (Waiting)
    Process cannot continue until some external event occurs. Waiting for I/O completion, signal, message, or resource. Multiple processes can be Blocked simultaneously. Organized in device queues or event queues.
    5. Terminated (Exit)
    Process has finished execution. OS deallocates resources and removes PCB. Short-lived transitional state before complete removal.

    Key Observations

    • A process is active only in Running state
    • A process is eligible to run in Ready state
    • A process is ineligible to run in Blocked state (even if CPU is free)
    • The transition from Blocked to Ready happens when the awaited event occurs
    • The transition from Ready to Running happens through CPU scheduling

    State Transition Diagram: All Possible Moves

    State Transition Diagram

    New Ready Running Blocked Terminated Admit Dispatch Preempt Wait Wake up Exit Impossible

    Transition Details

    TransitionTriggerDescription
    New -> ReadyAdmitOS creates process and loads it into memory
    Ready -> RunningDispatchScheduler assigns CPU to the process
    Running -> ReadyPreemptTime slice expires or higher priority process arrives
    Running -> BlockedWaitProcess requests I/O or waits for event
    Blocked -> ReadyWake upAwaited event occurs (I/O complete, signal received)
    Running -> TerminatedExitProcess completes execution or is killed

    Impossible Transitions

    • Blocked -> Running: must go through Ready first
    • Blocked -> Terminated: must wake up to Ready, then run, then terminate
    • Ready -> Blocked: only Running processes can block
    • New -> Running: must be admitted to Ready queue first
    • Terminated -> any state: process is done

    Critical insight: A Blocked process cannot run even if the CPU is idle. It must first be moved to Ready when its awaited event occurs.

    More notes in this unit