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
- Process Definition: Differentiate a “program” from a “process” and explain why a process is considered an “active entity.”
💡 View Solution
- Memory Segments: A process is divided into multiple memory segments. Briefly describe the contents of the following segments:
- Text Segment
- Data Segment (Initialized and Uninitialized/BSS)
- Heap
- Stack
💡 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
- State Identification: Define the exact condition of a process in the following states:
- Ready
- Waiting (Blocked)
- Terminated
💡 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.
- State Transitions: Explain the specific OS events that trigger the following state transitions:
- Running $\rightarrow$ Ready
- Running $\rightarrow$ Waiting
💡 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
- 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
- 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).
- The Overhead Dilemma: Why is a context switch considered “pure overhead” from the perspective of user processes?
💡 View Solution
Part D: Special Process Types and Kernel Interfaces
- 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
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.- The
/procFilesystem: The/procfilesystem provides a virtual interface to kernel data structures. If you query/proc/PID/statusfor a specific process, what do the fieldsVmSizeandVmRSSrepresent regarding resource usage?
💡 View Solution
/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).
- Task: If all processes always utilize their full time slice, calculate the percentage of CPU time spent entirely on context switching overhead. Show your calculation.
💡 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.
- Scenario: An executing background compilation task is preempted because the OS timer interrupt fires, signaling the end of its allocated time slice.
💡 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).