Operating System
Comprehensive exam revision notes for BCA-205N Unit 1 (Operating System Foundations, Architecture & Evolution). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.
Operating System
Operating System Foundations, Architecture & Evolution
Core Definitions & Key Concepts
An Operating System from both the user's and system's viewpoints
From the user's viewpoint, an Operating System (OS) is an extended machine (virtual machine) that provides an easy-to-use, convenient, and friendly abstraction layer hiding raw, complex hardware details. From the system's viewpoint, an OS is a resource manager that arbitrates and allocates finite hardware resources (CPU time, RAM, disk space, I/O devices) efficiently, fairly, and securely among competing processes.
Batch Operating Systems and Multiprogramming Operating Systems
| Feature | Batch Operating System | Multiprogramming Operating System |
|---|---|---|
| Job Execution | Similar jobs grouped into batches and processed sequentially without human intervention. | Multiple active jobs reside simultaneously in main memory ready to execute. |
| CPU Utilization | Low; CPU sits idle during slow mechanical I/O operations. | High; when the active process performs I/O, the OS context-switches CPU to another ready job. |
| Interaction | Zero direct interactive user access. | Semi-interactive or batch-multiprogrammed. |
What is Spooling and why was it an important milestone in OS evolution
SPOOLing (Simultaneous Peripheral Operations On-Line) uses high-speed disk storage as a massive buffer between slow peripherals (like card readers and printers) and the high-speed CPU. It decouples direct device I/O from processor speed, allowing background overlapping of data transfers and enabling early forms of multiprogramming.
Hard Real-Time Systems and Soft Real-Time Systems
In a Hard Real-Time System (e.g., pacemaker, missile guidance, nuclear plant reactor controls), missing a deadline constitutes a total catastrophic system failure. Zero jitter is tolerated. In a Soft Real-Time System (e.g., live video streaming, multiplayer gaming), missing a deadline causes quality degradation or latency hiccups but not catastrophic system collapse.
What is Dual-Mode Operation and what is the role of the Mode Bit
Dual-mode operation partitions hardware execution into User Mode (mode bit = 1) and Kernel/Supervisor Mode (mode bit = 0). Privileged machine instructions (like direct physical hardware I/O, disabling interrupts, modifying page tables) can strictly execute only in Kernel Mode. If user code attempts a privileged instruction, the CPU triggers an illegal instruction trap to prevent system corruption.
What is a System Call and how does it execute
A System Call is the programmatic mechanism by which a user-level application requests a privileged service from the operating system kernel. It executes by loading system call arguments into registers, issuing a software interrupt or trap instruction (e.g., sysenter, syscall, int 0x80), which switches the CPU from User Mode (1) to Kernel Mode (0) and jumps to the kernel's System Call Handler table.
Conceptual & Architectural Analysis
Compare Monolithic Kernel Architecture with Microkernel Architecture with a neat diagram
Monolithic vs Microkernel Architecture
Monolithic Kernel Architecture Microkernel Architecture
+------------------------------------+ +------------------------------------+
| User Space: User Applications | | User Space: Applications, File Sys |
| | | Server, Device Drivers, Net Server |
+------------------------------------+ +------------------------------------+
| Kernel Space: | | IPC (Message Passing) Boundary |
| - VFS / File System | +------------------------------------+
| - Virtual Memory & Paging | | Microkernel Space: |
| - Process Scheduling & Signals | | - Low-level Hardware Abstraction |
| - Hardware Device Drivers & Net | | - Basic Inter-Process Comm (IPC) |
| - Inter-Process Communication | | - Minimal CPU Scheduling & MM |
+------------------------------------+ +------------------------------------+
| Hardware Layer (CPU, RAM, Disks) | | Hardware Layer (CPU, RAM, Disks) |
+------------------------------------+ +------------------------------------+Detailed Comparison Matrix:
- Size & Complexity: Monolithic kernels compile all services (scheduling, memory, VFS, device drivers) into a single giant binary executing in supervisor mode. Microkernels strip the kernel down to essential primitives (IPC, low-level scheduling, basic MM) and move file systems and drivers into unprivileged user-space server daemons.
- Reliability & Fault Isolation: In a monolithic kernel, a single bug or null-pointer dereference in a third-party peripheral driver causes a complete Kernel Panic (Blue Screen). In a microkernel, if a driver crashes, only its user-space daemon dies and restarts; the core microkernel remains unaffected.
- Performance: Monolithic kernels are faster because all inter-component communication happens via direct C function calls with zero context switching. Microkernels suffer a performance penalty due to frequent context switches and user-to-kernel message passing overhead.
The step-by-step transition of CPU control during a System Call execution
System Call Execution Mechanism & Hardware Trap Flow
When a user application (such as a C program calling read() or write()) requests kernel services:
[User Space] [Kernel Space]
User Program: printf("Hello");
|
v
Calls C Library Wrapper (write())
|
Loads Syscall Number (e.g., 4) & args
into CPU Registers (EAX, EBX, etc.)
|
Executes Trap / SYSCALL Instruction ---> [Hardware Trap / Exception Raised]
|
+--> CPU hardware switches Mode Bit: 1 -> 0
| Switches to Kernel Stack
| Saves User Program Counter (PC) & State
v
Kernel System Call Handler dispatched
|
Consults System Call Table [Syscall_Num]
|
Executes sys_write() service routine
|
Places return value in EAX/RAX
v
Returns via IRET / SYSRET Instruction <-- Restores User Stack & State
| Switches Mode Bit: 0 -> 1
Resumes execution in User Program at PC+4- Parameter Passing Methods:
- Via CPU hardware registers (fastest, limited capacity).
- Via memory block/table, passing the block's base memory pointer in a register (e.g., Linux/Unix).
- Via pushing onto the program stack.
The evolution of Operating Systems from Serial Processing to Time-Sharing Systems
Operating System Evolution Milestones
- Serial Processing (1940s–1950s):
- Direct console access with plugboards and paper tapes.
- Programmers signed up for physical time slots. Enormous setup time (mounting tapes, card decks). CPU was idle >80% of the time.
- Simple Batch Systems (1950s–1960s):
- Introduction of JCL (Job Control Language) and Resident Monitors.
- Operators gathered jobs on magnetic tape; the resident monitor automatically transferred control from one job to the next.
- Multiprogrammed Batch Systems:
- Introduced partitioned memory holding multiple jobs simultaneously.
- Whenever Job A initiated I/O, the OS switched the CPU to Job B. Tremendously increased CPU utilization and system throughput.
- Time-Sharing Systems (Multitasking - 1970s onwards):
- Introduced logical slicing of CPU time (Time Quantum / Time Slice) using hardware timer interrupts.
- The CPU rapidly cycles through active interactive users, granting each ~10–50 ms. Users experience the illusion of having a dedicated computer.
In-Depth Analysis & Implementation
Discuss Operating System System Calls in detail. Classify them into major functional categories and explain representative system calls in Unix/Linux with syntax and functionality
Comprehensive Classification of Operating System System Calls
System calls form the fundamental application programming interface (API) between user applications and the OS kernel.
+------------------------------------------+
| OS System Call Families |
+------------------------------------------+
| | | |
+---------------+ | | +---------------+
| | | |
v v v v
Process Control File Management Device Management IPC & Networking
(fork, exec, exit, wait) (open, read, write) (ioctl, read, write) (pipe, shmget, socket)1. Process Control System Calls
- `pid_t fork(void)`: Duplicates the calling process, creating an exact child process with separate address space. Returns
0to the child, returns Child PID to the parent, and returns-1on error. - *`int execve(const char path, char const argv[], char const envp[])`**: Replaces the current process memory image (text, data, heap, stack) with a new executable binary.
- `void exit(int status)`: Terminates the calling process, frees resources, and returns status code to waiting parent.
- *`pid_t wait(int status)`**: Suspends the parent process until one of its child processes terminates, preventing Zombie processes.
2. File Manipulation System Calls
- *`int open(const char pathname, int flags, mode_t mode)`**: Opens file and returns a non-negative file descriptor index.
- *`ssize_t read(int fd, void buf, size_t count)
**: Reads up tocountbytes from open file descriptorfdinto bufferbuf`. - *`ssize_t write(int fd, const void buf, size_t count)
**: Writes bytes from bufferbufto file descriptorfd`. - `int close(int fd)`: Flushes buffers, releases file locks, and frees the file descriptor table entry.
3. Device Management System Calls
- `ioctl(int fd, unsigned long request, ...)`: Device-specific control operations (e.g., setting terminal baud rate, ejecting CD-ROM, configuring network adapters).
4. Information Maintenance System Calls
- `getpid()`, `alarm()`, `sleep()`, `time()`: Inquires system clock, elapsed time, process ID, and scheduling timers.
5. Inter-Process Communication (IPC) System Calls
- `int pipe(int pipefd[2])`: Creates a unidirectional data channel in kernel memory (
pipefd[0]for read,pipefd[1]for write). - `shmget()` & `shmat()`: Allocates and attaches a shared physical memory segment across distinct process address spaces.
Analyze the architectural design choices of modern operating systems: Monolithic, Layered, Microkernel, and Hybrid Architectures. Evaluate their trade-offs in security, maintainability, and execution speed
Comparative Architectural Analysis of Operating System Kernels
The structural organization of an operating system dictates its modularity, security posture, and raw computational efficiency.
1. Monolithic Architecture (e.g., Traditional UNIX, Linux, BSD)
- Structure: Every subsystem (Virtual Memory, VFS, Network Stack, IPC, Character/Block Device Drivers, CPU Scheduler) runs in the same flat supervisor address space.
- Advantages: Unrivaled speed and zero IPC overhead. Data structures can be accessed directly across modules.
- Disadvantages: Huge monolithic footprint (>30 million lines in modern Linux). A single null-pointer dereference in a webcam driver crashes the entire kernel.
2. Layered Architecture (Dijkstra's THE System)
- Structure: OS is decomposed into N concentric hierarchical layers (Layer 0 = Hardware, Layer N = User Interface). Each layer i can invoke services strictly from lower layers i-1, i-2, \dots, 0.
- Advantages: Clean modularity, straightforward debugging and verification (Layer 0 verified first, then Layer 1, etc.).
- Disadvantages: Inefficient execution path. A simple disk read must traverse through multiple intermediate layers, adding function call and translation overheads.
3. Microkernel Architecture (e.g., Mach, QNX, L4)
- Structure: Removes all non-essential services from the kernel. Only thread scheduling, low-level memory mappings, and inter-process communication (IPC) remain inside the kernel. File systems, networking, and drivers run as user-mode servers.
- Advantages: High fault tolerance, high security, dynamic live restart of crashed subsystems.
- Disadvantages: Significant overhead due to continuous message passing and multiple context switches between user mode and kernel mode for standard I/O.
4. Modern Hybrid Architecture (e.g., Windows NT, macOS XNU)
- Structure: Combines the performance of monolithic kernels with the modular abstractions of microkernels.
- Implementation: Windows NT Executive runs core servers and drivers in kernel space for speed, but encapsulates them into strictly defined object-oriented modular layers with protected interfaces.
Important Exam Points & Quick Revision
Examiner Insights & University Exam Strategy:
- Compulsory Questions: Expect a 2-mark question on Dual Mode Operation / Mode Bit or Spooling vs Multiprogramming.
- 5-Mark Question: The comparison between Monolithic Kernel vs Microkernel is asked in almost every alternate examination. Always accompany your answer with a neat two-box architectural diagram showing User Space vs Kernel Space.
- 10-Mark Question: If asked about System Calls, provide a clean step-by-step diagram illustrating the transition from User Mode to Kernel Mode via hardware trap, and classify calls with Linux examples (
fork,exec,wait,exit,open,read,write).
100% left on this page — finishing it closes the gap for Operating System Foundations, Architecture & Evolution.
Operating System Foundations, Architecture & Evolution still counts as a weak topic until you finish this note and answer its questions.
Practise this unitTest Your Understanding
Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.