What are the main components of a computer system?
Briefly describe each
with proper diagram.
The main components of a computer system are typically divided into four parts:
1. Hardware
Physical parts of the computer system.
• Includes CPU, memory, storage, input/output devices
• CPU performs processing
• Memory stores data temporarily (RAM)
• Storage (HDD/SSD) stores data permanently
2. Operating System (OS)
Acts as an interface between hardware and users.
• Manages hardware resources (CPU, memory, I/O)
• Controls execution of programs
• Examples: Windows OS, Linux
3. Application Programs
Software that performs specific tasks for users.
• Examples: web browsers, compilers, database systems
• Helps users solve real-world problems
• Examples include Google Chrome, Microsoft Word
4. Users
People or other systems that interact with the computer.
• End users, programmers, or other computers
• Provide input and receive output
Define a Real-Time Operating System (RTOS). Briefly differentiate between a
Hard Real-Time System and a Soft Real-Time System, providing specific
application and example for each.
Definition of Real-Time Operating System (RTOS)
A Real-Time Operating System (RTOS) is an operating system designed to
process data and respond to events within a strict time constraint.
The correctness of an RTOS depends not only on the logical result but also on the
time at which the result is produced.
Types of Real-Time Systems
1. Hard Real-Time System
A Hard Real-Time System is one where meeting deadlines is absolutely critical.
• If a deadline is missed → system failure may occur
• Requires guaranteed response time
Application:
• Aircraft control systems
• Medical life-support systems
Example:
• Flight control system in an aircraft
• Pacemaker in healthcare
2. Soft Real-Time System
A Soft Real-Time System is one where deadlines are important but not strictly
mandatory.
• Missing deadlines → performance degradation, not failure
• More flexible compared to hard RTOS
Application:
• Multimedia systems
• Online video streaming
Example:
• Video streaming platforms like YouTube
• Online gaming systems
System calls represent the fundamental interface between a running
application (user mode) and the Operating System kernel (kernel mode).
Systematically analyze the concept of System Calls, detailing the mechanism
of their execution, their necessity, and their classification based on the services
they provide.
Concept of System Calls
System calls are the interface between user programs (user mode) and the
Operating System kernel (kernel mode).
They allow a program to request services such as file handling, process control,
and device access from the OS.
Mechanism of Execution (How System Calls Work)
1. User Program Request
o An application (e.g., C Program) needs a service (like reading a file).
2. System Call Invocation
o The program calls a library function (e.g., read(), write()).
3. Trap / Interrupt
o A special instruction (software interrupt or trap) transfers control to
the kernel.
4. Mode Switch
o CPU switches from user mode → kernel mode.
5. Kernel Execution
o OS performs the requested task (e.g., accessing disk).
6. Return to User Mode
o Control returns to the user program with results.
Necessity of System Calls
System calls are essential because:
• Security: Prevent direct hardware access by user programs
• Abstraction: Simplify complex hardware operations
• Resource Management: OS controls CPU, memory, and I/O
• Standard Interface: Provides a consistent way to interact with OS
Without system calls, applications would need to directly control hardware, which
is unsafe and inefficient.
Classification of System Calls
System calls are categorized based on the services they provide:
1. Process Control
• Create, terminate, and manage processes
• Examples: fork(), exit()
2. File Management
• Create, read, write, delete files
• Examples: open(), read(), write()
3. Device Management
• Request and release I/O devices
• Examples: device read/write operations
4. Information Maintenance
• Get/set system data (time, process info)
• Examples: getpid(), time()
5. Communication
• Enable inter-process communication (IPC)
• Examples: pipes, message passing
6. Protection
• Control access permissions and security
• Examples: chmod(), access()
Spooling is a core technique employed by Operating Systems to manage
peripheral devices, especially in the context of print services and batch
processing. Critically analyze the role, mechanism, and importance of
Spooling in modern operating systems.
Concept of Spooling
Spooling (Simultaneous Peripheral Operations On-Line) is an OS technique
where data is temporarily stored in a buffer (usually disk) so that slow I/O
devices (like printers) can process it sequentially and efficiently.
Mechanism of Spooling (How it Works)
1. Job Submission
o Multiple processes send I/O requests (e.g., print jobs).
2. Spool Queue Creation
o OS stores these jobs in a disk-based queue (spool).
3. Buffering
o Data is written to disk instead of directly to the device.
4. Device Scheduling
o OS selects jobs from the queue (FIFO or priority-based).
5. Execution
o Device (e.g., printer) processes jobs one by one.
Role of Spooling in OS
• Acts as an intermediary between processes and I/O devices
• Enables asynchronous processing (CPU doesn’t wait for I/O)
• Manages multiple requests efficiently
• Supports batch processing systems
Importance of Spooling
1. Improves System Efficiency
• CPU can continue executing other tasks while I/O is handled separately
2. Better Device Utilization
• Keeps devices like printers busy with queued jobs
3. Handles Multiple Users
• Multiple users can send requests simultaneously
4. Reduces Waiting Time
• Eliminates direct contention for devices
5. Supports Batch Processing
• Essential for systems where jobs are processed in batches
Critical Analysis
Advantages
• Increases throughput and performance
• Enables multitasking
• Provides organized job scheduling
• Reduces idle time of CPU and devices
Limitations
• Requires additional disk space for spool storage
• Delay may occur for large queues
• Risk of job loss if system crashes (without recovery mechanisms)
Modern Use of Spooling
• Print management systems in operating systems like Windows OS and Linux
• Background job processing (e.g., email queues, task schedulers)
• Server-side request handling in large-scale systems
The Process Control Block (PCB) serves as the 'identity card' and 'storage
container' for every process in an Operating System. Systematically analyze
the structure, function, and importance of the PCB in facilitating the core
services of the OS, particularly process switching and scheduling.
Process Control Block (PCB)
The Process Control Block (PCB) is a data structure maintained by the
Operating System that stores all essential information about a process.
It acts as the “identity card” and “information hub” for each process.
Structure of PCB (Main Components)
A PCB typically contains the following fields:
1. Process Identification
• Process ID (PID)
• Parent process ID
2. Process State
• Current state (new, ready, running, waiting, terminated)
3. Program Counter
• Address of the next instruction to be executed
4. CPU Registers
• General-purpose registers, stack pointer, etc.
5. CPU Scheduling Information
• Priority, queue pointers, scheduling parameters
6. Memory Management Information
• Base/limit registers, page tables, segment tables
7. Accounting Information
• CPU usage, time limits, process number
8. I/O Status Information
• List of allocated devices, open files
Functions of PCB
• Process Management: Stores all process-related data
• State Tracking: Keeps track of process state transitions
• Resource Allocation: Maintains memory and I/O details
• Execution Control: Helps resume process execution correctly
Role in Process Switching (Context Switching)
PCB is critical in context switching:
1. When CPU switches from one process to another:
o Current process state is saved into its PCB
2. Next process is selected:
o Its state is restored from its PCB
3. Execution resumes from saved point
Without PCB, process switching would be impossible
Role in Scheduling
• Scheduler uses PCB to:
o Access process state
o Determine priority and scheduling policy
o Manage ready/waiting queues
• PCB helps OS decide:
o Which process runs next
o How long it runs
Importance of PCB
1. Enables Multitasking
• Multiple processes can run efficiently
2. Supports Context Switching
• Ensures smooth switching without data loss
3. Centralized Process Information
• All process data stored in one place
4. Improves Scheduling Efficiency
• Helps OS make optimal decisions
5. Ensures System Stability
• Proper tracking prevents errors and conflicts
Critical Analysis
Advantages
• Efficient process tracking and control
• Essential for modern multitasking OS
• Enables advanced scheduling algorithms
Limitations
• Memory overhead for storing PCBs
• Frequent updates during context switching can add overhead
Semaphores are an essential synchronization tool used by Operating Systems
to solve the Critical Section Problem and manage concurrent access to shared
resources. Describe the structure and operation of Semaphores and evaluate
their strengths and weaknesses as a synchronization mechanism.
Structure of Semaphore
A semaphore is a synchronization variable:
• Integer value (S)
• Queue (for waiting processes)
Types:
• Binary Semaphore (0/1) → Mutex
• Counting Semaphore → Multiple resources
Operations
1. wait(S) / P()
• Decreases S
• If S < 0 → process blocked
2. signal(S) / V()
• Increases S
• Wakes up waiting process
Working Mechanism
• Ensures only one process enters critical section
• Prevents race condition
Strengths
✔ Simple and powerful
✔ Supports multiple processes
✔ Efficient for resource sharing
✔ Works in low-level system design
Weaknesses
Difficult to debug
Can cause deadlock
Possible starvation
Priority inversion problem
Compare and contrast monolithic, layered and microkernel operating system
structures in terms of performance, reliability, and design complexity.
Explanation
Monolithic
• All services in one kernel
• Fast but less secure
Layered
• OS divided into layers
• Easier to debug
Microkernel
• Minimal kernel, services in user space
• Very secure but slower
How does the distinction between kernel mode and user mode function as a
rudimentary form of protection (security)?
Kernel Mode vs User Mode as a Protection Mechanism
The distinction between user mode and kernel mode is a fundamental way the
Operating System enforces basic security and system protection.
What are the Modes?
1. User Mode
• Where applications run (e.g., Google Chrome)
• Has limited privileges
• Cannot directly access hardware or critical memory
2. Kernel Mode
• Where the Operating System core runs (e.g., Linux kernel)
• Has full access to:
o CPU instructions
o Memory
o I/O devices
How It Provides Protection
1. Restricted Access to Hardware
• User programs cannot directly access hardware
• Must request through system calls
Prevents misuse or damage
2. Memory Protection
• User mode processes cannot access kernel memory
• Prevents:
o Data corruption
o Unauthorized access
3. Controlled Execution of Privileged Instructions
• Sensitive instructions (I/O control, memory management)
• Only allowed in kernel mode
Stops malicious operations
4. Fault Isolation
• If a user program crashes → only that program fails
• Kernel and other processes remain safe
5. Secure System Call Interface
• Acts as a gatekeeper between user and kernel
• OS validates every request
Critical Analysis
Advantages
✔ Prevents unauthorized access
✔ Protects system stability
✔ Enables safe multitasking
✔ Isolates faults
Limitations
Mode switching adds overhead
Not sufficient alone (needs additional security mechanisms)
Explain the layered approach to operating system design. What are the
advantages and disadvantages of using this approach?
Layered Approach to Operating System Design
The layered approach organizes the Operating System into a hierarchy of layers,
where each layer performs a specific function and interacts only with adjacent
layers.
• The lowest layer interacts directly with hardware
• The highest layer provides services to user applications
Structure of Layered OS
Each layer:
• Uses services of the lower layer
• Provides services to the upper layer
Explanation
• Hardware Layer: Physical components
• Device Drivers: Control hardware devices
• Memory Management: Handles memory allocation
• Process Management: Manages processes and CPU scheduling
• File System: Manages files and storage
• System Call Interface: Bridge between OS and applications
• Applications: User programs
Advantages
1. Modularity
• Each layer is independent
• Easy to design and update
2. Ease of Debugging
• Errors can be isolated within a layer
3. Maintainability
• Changes in one layer don’t affect others
4. Security & Protection
• Restricted access between layers
Disadvantages
1. Performance Overhead
• Each request passes through multiple layers
2. Difficult Layer Definition
• Hard to divide system functions properly
3. Reduced Efficiency
• Extra communication between layers slows execution
Example
• Early layered OS: THE system
• Modern systems (partially layered): Windows OS, Linux
What is the purpose of system call? How the system call write() can be
implemented?
Purpose of System Calls
A system call is the only controlled way for a user program to request services
from the Operating System kernel.
Main Purposes
• Access Hardware Safely
User programs cannot directly access devices → must go through OS
• Provide Standard Interface
Common functions like file handling, process control
• Ensure Protection & Security
Prevents unauthorized memory or device access
• Resource Management
OS controls CPU, memory, I/O efficiently
Example: Writing data to a file using write()
How write() System Call is Implemented
The write() system call is used to write data to a file or output device.
Key Points (Exam Focus )
• write() is a file management system call
• Uses file descriptor (fd)
• Involves mode switching
• Ensures safe and controlled I/O
Describe the actions taken by a kernel to context-switch between processes.
When switching processes, the kernel performs:
Steps in Context Switching
1. Save Current Process State
• Store in PCB:
o Program Counter
o CPU Registers
o Stack Pointer
2. Update Process State
• Running → Ready / Waiting
3. Select Next Process
• Scheduler chooses next process
4. Load New Process State
• Restore:
o Registers
o Program counter
5. Switch Address Space
• Update memory mappings
6. Resume Execution
• CPU starts executing new process
Explain the concept of Process Control Block data structure, that is
maintained by the operating system to keep track of a particular process.
A Process Control Block (PCB) is a data structure maintained by the OS that
stores all information about a process.
It contains:
• Process ID (PID)
• Process state (ready, running, waiting)
• Program counter
• CPU registers
• Memory & I/O information
Purpose:
Helps the OS to track, schedule, and switch processes efficiently (context
switching uses PCB).
Why process synchronization is important? How inter process communication
is achieved using shared memory approach ?
Why Process Synchronization is Important
• Prevents race condition
• Ensures data consistency
• Controls access to shared resources
Shared Memory IPC
Concept:
• Processes share a common memory region
Steps:
1. Create shared memory
2. Attach processes
3. Read/write data
4. Use synchronization (semaphore)
Advantage:
✔ Fast (no kernel involvement after setup)
Problem:
Needs synchronization control
Describe the interrupt handling process in an operating system
An interrupt is a signal that makes the CPU pause current execution and handle
an urgent event.
Steps of Interrupt Handling
1. Interrupt Occurs
o From hardware (keyboard, I/O) or software
2. Save Current State
o CPU saves registers, program counter into PCB/stack
3. Switch to Kernel Mode
o CPU enters privileged mode
4. Interrupt Service Routine (ISR)
o OS executes specific handler for that interrupt
5. Restore State
o Previous process state restored
6. Resume Execution
o Program continues from where it stopped
How does a user program make a system call?
Steps:
1. User Program Calls Function
o Example: read(), write()
2. Library Wrapper Used
o Provided by GNU C Library
3. System Call Instruction (Trap)
o CPU switches User Mode → Kernel Mode
4. Kernel Executes Service
o Performs requested operation
5. Return to User Mode
o Result sent back to program
Explain the benefits of multiprogramming and multitasking. How do they
improve system efficiency and user experience?
Multiprogramming
• Multiple programs kept in memory
• CPU switches when one waits for I/O
✔ Benefits:
• Better CPU utilization
• Reduced idle time
Multitasking
• CPU rapidly switches between tasks
✔ Benefits:
• Interactive system
• Multiple applications run simultaneously
Overall Improvement
Aspect Improvement
Efficiency CPU always busy
Throughput More tasks completed
User Experience Smooth, responsive system
List five services provided by an operating system, and explain how each
creates convenience for users.
Process Management → runs programs
Memory Management → allocates RAM
File System → manages files
Device Management → controls hardware
Security & Protection → prevents unauthorized access
Compare and contrast different approaches to operating system structures:
Microkernel, Layered and Hybrid.
Feature Microkernel Layered Hybrid
Performance Lower Medium High
Feature Microkernel Layered Hybrid
Reliability High Medium High
Design Modular Structured Mixed
Examples:
• Microkernel → MINIX
• Hybrid → Windows OS
Compare the performance implications of context switching in different time
quantum.
Small Time Quantum
• More context switching
• Higher overhead
• Better responsiveness
Large Time Quantum
• Less switching
• Lower overhead
• Poor responsiveness
Investigate the impact of multithreading on performance and resource
utilization.
Multithreading allows a process to run multiple threads concurrently.
Performance Impact
• Improved responsiveness → UI stays active while background work runs
• Better CPU utilization → multiple threads use CPU efficiently
• Parallelism → on multi-core systems, threads run simultaneously
• Faster execution → tasks split into smaller parts
Resource Utilization
• Threads share:
o Same memory space
o Same resources
Less overhead than processes
Advantages
✔ Efficient communication (shared memory)
✔ Low creation cost
✔ High throughput
Disadvantages
Synchronization complexity
Race conditions
Debugging is difficult