1 Operating Systems and Architecture
1 Operating Systems and Architecture
Architecture: An Introduction
Understanding the Core of Modern Computing
Mavhemwa P.M
What is an Operating System (OS)?
•Definition: An Operating System (OS) is a software program that manages computer hardware and
•software resources, provides common services for computer programs, and acts as an intermediary
•between the user and the computer hardware.
•Purpose:
•Resource Management: Allocates and deallocates CPU time, memory, storage, and I/O devices.
•Program Execution: Provides an environment for applications to run.
•User Interface: Offers a way for users to interact with the computer (GUI, CLI).
•Error Detection and Handling: Manages and responds to errors in hardware and software.
Types of Operating Systems
•Batch Operating Systems:
•Jobs processed in batches; no direct user interaction during execution.
•Example: Early mainframes for payroll, billing.
•Time-Sharing (Multitasking) Operating Systems:
•Allows multiple users/programs to share a single CPU by rapidly switching between them.
•Example: UNIX, Linux, Windows (desktop versions).
•Real-Time Operating Systems (RTOS):
•Guarantees completion of tasks within specific time constraints.
•Types: Hard real-time (critical, no delays) and soft real-time (tolerates minor delays).
•Example: Industrial control systems, medical imaging, robotics.
•Distributed Operating Systems:
•Manages a group of independent computers and makes them appear as a single coherent system.
•Example: Amoeba, Plan 9.
•Network Operating Systems:
•Runs on a server, providing network services to connected clients (e.g., file sharing, printing).
•Example: Windows Server, Novell NetWare.
•Mobile Operating Systems:
•Designed for smartphones and tablets, emphasizing touch interfaces and power efficiency.
•Example: Android, iOS.
Evolution of Operating Systems
•1940s-1950s: No OS (Manual Operation)
•Programs loaded manually via plugboards or punched cards.
•Extremely inefficient utilization of expensive hardware.
•1950s-1960s: Batch Systems
•Monitors and resident programs automate job sequencing.
•Introduction of job control languages (JCL).
•1960s-1970s: Multiprogramming & Time-Sharing
•Multiple jobs in memory simultaneously, CPU switches between them.
•Emergence of interactive computing. UNIX developed.
•1970s-1980s: Personal Computers & GUIs
•Development of microcomputers. DOS, Macintosh OS with graphical user interfaces.
•1990s-2000s: Networked & Distributed Systems
•Growth of the Internet, client-server models, Windows NT, Linux gains popularity.
•2000s-Present: Mobile, Cloud & Virtualization
•Dominance of mobile OS (Android, iOS), cloud computing, extensive use of virtualization.
Operating System: Structure and Functions
• OS Structure (Common Models):
• Monolithic Structure:
• Entire OS runs in kernel mode as a single program.
• Pros: High performance due to direct function calls.
• Cons: Difficult to debug, extend, and maintain; less stable (a bug can crash the whole system).
• Example: Early UNIX, Linux (hybrid).
• Layered Structure:
• OS divided into layers, each performing specific functions.
• Pros: Modular, easier to debug and modify.
• Cons: Performance overhead due to multiple layer crossings.
• Microkernel Structure:
• Only essential services (process management, memory management, IPC) in the kernel.
• Other services (file system, device drivers) run as user-level processes.
• Pros: High reliability (failure of a service doesn't crash kernel), extensibility.
• Cons: Performance overhead due to inter-process communication.
• Example: Mach, QNX.
Operating System: Structure and Functions (Cont.)
• Key Functions of an OS:
1. Process Management:
1. Creating and deleting processes.
2. Scheduling processes (CPU allocation).
3. Process synchronization and inter-process communication (IPC).
4. Deadlock handling.
2. Memory Management:
1. Allocating and deallocating memory space to processes.
2. Keeping track of which parts of memory are being used by whom.
3. Swapping, paging, and segmentation.
3. Storage Management (File System Management):
1. Creating and deleting files and directories.
2. Mapping files onto secondary storage.
3. File access control and protection.
4. I/O System Management:
1. Managing device drivers.
2. Buffering, caching, and spooling.
3. Providing a device-independent interface.
5. Protection and Security:
1. Controlling access to system resources.
2. Protecting against internal and external threats.
6. Command-Interpreter System (Shell):
1. User interface for interacting with the OS.
File System Structure and Management
•File: A named collection of related information stored on secondary storage.
•Directory (Folder): A collection of files and other directories, organizing the file system hierarchically.
File System Structure:
•Boot Control Block: Information needed to boot the OS.
•Volume Control Block (Superblock): Details about the file system volume (e.g., total blocks, free
blocks).
•Directory Structure: Organizes files (e.g., tree-structured, acyclic-graph).
•File Control Block (Inode): Per-file details (permissions, dates, size, data block pointers).
•File Management Operations:
•Creating/Deleting Files: OS allocates/deallocates space.
•Opening/Closing Files: Prepares/releases file for access.
•Reading/Writing Files: Data transfer between disk and memory.
•Seeking: Moving the read/write pointer within a file.
•Access Control: Permissions (read, write, execute) for users/groups.
•Disk Space Allocation Methods:
•Contiguous allocation, linked allocation, indexed allocation.
OS Selection Considerations
•Hardware Compatibility: Does the OS support the computer's CPU, memory, and peripherals?
•Application Requirements: Are the necessary applications available and compatible with the OS?
•Performance:
•Speed (boot time, application launch).
•Efficiency (resource utilization).
•Responsiveness (UI fluidity).
•Security:
•Robustness against malware and unauthorized access.
•Regular updates and patches.
•Reliability and Stability:
•How often does the system crash or become unresponsive?
•Cost:
•Licensing fees (for commercial OS).
•Maintenance and support costs.
•Ease of Use (Usability):
•User interface intuitiveness.
•Availability of documentation and community support.
•Specific Features:
•Virtualization support, networking capabilities, specific development tools.
Computer System Structures: Organization &
Operations
•Modern Computer System Components:
•CPU (Central Processing Unit): The "brain," executes instructions.
•Memory (RAM): Volatile storage for programs and data currently in use.
•I/O Devices: Peripherals (keyboard, mouse, monitor, disk drives, network cards).
•Buses: Communication pathways connecting components (e.g., data bus, address bus,
control bus).
•Basic Operation Cycle:
1.CPU fetches instruction from memory.
2.CPU decodes instruction.
3.CPU executes instruction.
4.Repeat.
•Bootstrap Program:
•Initial program loaded when the computer starts (firmware in ROM/EEPROM).
•Initializes all aspects of the system, loads the OS kernel into memory, and starts its
execution.
CPU Operations: Interrupts and Handling
•Interrupt: A signal that temporarily suspends the execution of a program and causes control to pass
to a special routine (Interrupt Service Routine - ISR) to handle an event.
•Why Interrupts?
•Efficiency: Allows CPU to do other work while waiting for I/O completion.
•Responsiveness: Enables the system to react quickly to urgent events (e.g., key press,
network packet arrival, hardware error).
•Types of Interrupts:
•Hardware Interrupts: Generated by I/O devices (e.g., disk completion, timer expiration).
•Software Interrupts (Traps/Exceptions): Generated by a program's execution (e.g., division by zero,
•system call, page fault).
•Interrupt Handling Process:
1.Device/program sends an interrupt signal.
2.CPU finishes current instruction.
3.CPU saves the current state (registers, program counter).
4.CPU determines the cause of the interrupt (via Interrupt Vector Table).
5.CPU transfers control to the appropriate Interrupt Service Routine (ISR).
6.ISR handles the event.
7.CPU restores the saved state.
8.CPU resumes the interrupted program.
I/O Methods
•1. Programmed I/O (PIO):
•CPU continuously checks (polls) the status of an I/O device until it's ready for data transfer.
•Pros: Simple to implement.
•Cons: Wastes CPU cycles, inefficient for slow devices.
•2. Interrupt-Driven I/O:
•CPU issues an I/O command and then continues with other tasks.
•The I/O device interrupts the CPU when it completes the operation or needs attention.
•Pros: More efficient than PIO, CPU is not idled.
•Cons: Still involves CPU for data transfer for each word/byte.
•3. Direct Memory Access (DMA):
•Concept: A specialized hardware component (DMA controller) manages data transfer directly between I/O
devices and main memory, without involving the CPU.
•Process:
1.CPU programs the DMA controller (source, destination, size).
2.CPU proceeds with other tasks.
3.DMA controller performs the transfer.
4.DMA controller interrupts CPU upon completion.
•Pros: Highly efficient for large data transfers, frees up CPU for other computations.
•Cons: Requires dedicated DMA controller hardware.
Device Status Table & Storage Organization