Assignment 02: Process Concepts and the Process Control Block

Self-Assessment

Instructions: Answer the following questions concisely. For analytical and calculation questions, ensure you justify your reasoning based on operating system principles.

Part A: Process Fundamentals and Memory Layout

  1. Process Definition: Differentiate a “program” from a “process” and explain why a process is considered an “active entity.”
💡 View Solution
Definition: A program is passive code, while a process is an instance of a program in execution. A process is an active entity because it encompasses the current state of the CPU, associated data, and allocated system resources.
  1. Memory Segments: A process is divided into multiple memory segments. Briefly describe the contents of the following segments:
💡 View Solution
  • Text Segment: Contains the compiled, read-only executable instructions.

  • Data Segment: Contains global and static variables. Initialized data holds variables with assigned values, while Uninitialized Data (BSS) holds declared variables without initial values.

  • Heap: Contains dynamically allocated memory during runtime (e.g., using malloc).

  • Stack: Contains temporary data such as function parameters, return addresses, and local variables.

Part B: Process States and Transitions

  1. State Identification: Define the exact condition of a process in the following states:
💡 View Solution
  • Ready: The process is loaded into main memory, is runnable, and is awaiting CPU allocation.

  • Waiting (Blocked): The process cannot execute immediately because it is waiting for an event to occur, such as I/O completion or resource availability.

  • Terminated: The process has finished execution and is awaiting final cleanup by the operating system.

  1. State Transitions: Explain the specific OS events that trigger the following state transitions:
💡 View Solution
  • Running $\rightarrow$ Ready: This transition occurs due to a time slice expiration or scheduler preemption.

  • Running $\rightarrow$ Waiting: This transition occurs when the process issues an I/O request or waits for a specific event.

Part C: The Process Control Block (PCB) and Context Switching

  1. PCB Anatomy: The Process Control Block is the OS’s comprehensive “identity card” for each active process. List at least four specific categories of information stored within a PCB.
💡 View Solution
A PCB stores: Process Identification (PID, Parent PID), Process State, CPU State Information (Registers, Program Counter), Memory Management Information (Page table pointers), Scheduling Information (Priority, Queue pointers), I/O Status Information, and Accounting Information.
  1. Context Switching Mechanism: Detail the three distinct phases of a context switch.
💡 View Solution
  • Phase 1: Save Current State (OS saves the complete CPU state of the running process into its PCB).

  • Phase 2: Load Next State (OS loads the saved CPU state from the PCB of the next selected process).

  • Phase 3: Dispatch (CPU begins execution from the loaded Program Counter of the new process).

  1. The Overhead Dilemma: Why is a context switch considered “pure overhead” from the perspective of user processes?
💡 View Solution
Context switching is pure overhead because the CPU performs absolutely no useful work for the user processes during the switch; it strictly consumes CPU cycles and memory bandwidth to save and load states.

Part D: Special Process Types and Kernel Interfaces

  1. Zombie vs. Orphan: Explain the fundamental difference between a Zombie process and an Orphan process. Why is a large accumulation of Zombie processes a serious system concern?
💡 View Solution
A Zombie process has terminated, but its PCB remains in the process table because its parent has not called wait() to collect its exit status. An Orphan process is a running process whose parent has terminated; it is subsequently adopted by the init process. Too many Zombie processes can exhaust the system’s PID space, preventing new processes from being created.
  1. The /proc Filesystem: The /proc filesystem provides a virtual interface to kernel data structures. If you query /proc/PID/status for a specific process, what do the fields VmSize and VmRSS represent regarding resource usage?
💡 View Solution
In /proc/PID/status, the VmSize field represents the current virtual memory size of the process. The VmRSS field represents the Resident Set Size, which is the actual physical memory currently used by the process (excluding swapped-out portions).

Part E: Advanced Synthesis & Application (Exam Preparation)

Exercise 1: Context Switching Performance Calculations Assume an operating system performs a context switch that takes exactly $10 \mu s$ (microseconds) to execute. The CPU scheduler is configured with a time slice of $10 ms$ (milliseconds).

💡 View Solution
  • Calculation:

  • Context Switch Time = $10 \mu s$

  • Time Slice = $10 ms = 10,000 \mu s$

  • Total Cycle Time = $10,000 \mu s + 10 \mu s = 10,010 \mu s$

  • Percentage Overhead = $\frac{10}{10,010} \times 100$

  • Result: The overhead is approximately $0.0999\%$.

Exercise 2: PCB State Mapping For the following scenario, identify the most likely process state transition and the specific PCB fields that the operating system must actively update.

💡 View Solution
  • State Transition: The process transitions from the Running state to the Ready state.

  • PCB Fields Updated: The OS must update the Process State (from Running to Ready). It must save the CPU State Information (Registers, Program Counter, Stack Pointer). It must also update Accounting Information (CPU time used) and Scheduling Information (re-inserting the pointer into the Ready Queue).

SDB Watermark