Operating System Module 1 - Computer System & Operating System Overview

Computer System Overview: Basic Elements and Internal Registers

  • Main Structural Elements: A computer consists of processor, memory, and I/O components, with one or more modules of each type interconnected to execute programs. The four main structural elements are:

    • Processor: Controls the operation of the computer and performs its data processing functions. When a system features only one processor, it is referred to as the Central Processing Unit (CPU).
    • Main Memory: Stores data and programs. It is typically volatile (contents are lost when the system powers down). In contrast, disk memory retains contents when powered off. Main memory is also designated as real memory or primary memory.
    • I/O Modules: Move data between the computer and its external environment, which includes secondary memory devices (such as disks), communications equipment, and terminals.
    • System Bus: Provides communication infrastructure among processors, main memory, and I/O modules.
  • Top-Level Internal Processor Registers:

    • Memory Address Register (MAR): Specifies the address in memory for the next read or write operation.
    • Memory Buffer Register (MBR): Contains the data to be written into memory or receives data read from memory.
    • I/O Address Register (I/OAR): Specifies a particular I/O device.
    • I/O Buffer Register (I/OBR): Facilitates data exchange between an I/O module and the processor.
  • Module Architectures:

    • Memory Module: Consists of a set of locations defined by sequentially numbered addresses. Each location contains a bit pattern interpreted as an instruction or data.
    • I/O Module: Transfers data from external devices to the processor and memory, and vice versa. It contains internal buffers for temporarily holding data until transmission.
  • User-Visible Registers (UVR):

    • Accessible to programmers to minimize main memory references.
    • Includes general-purpose and special-purpose registers (e.g., dedicated registers for floating-point operations versus integer operations).
    • Index Register: Involves adding an index value to a base value to generate an address.
    • Segment Pointer: References memory via a segment identifier and an offset when memory is segmented.
    • Stack Pointer: Points to the top of the stack.
    • Includes general Data Registers and Address Registers.
  • Control and Status Registers:

    • Used by the processor to control operations and by privileged operating-system routines to control program execution.
    • Program Counter (PC): Contains the address of the next instruction to be fetched.
    • Instruction Register (IR): Contains the instruction most recently fetched.
    • Program Status Word (PSW): Contains hardware and status information.
    • Condition Codes / Flags: Bits set by processor hardware as a result of operations (e.g., Positive, Negative, Zero, Overflow).
  • Processor Register Definition:

    • Local storage space on the processor holding data being processed by the CPU.
    • Occupies the top-most position in the memory hierarchy, providing high-speed storage and ultra-fast data access.
    • Registers can store either actual operational data or memory addresses.

Instruction Execution Cycle

  • Instruction Processing Basics:

    • A program consists of a set of instructions stored in memory.
    • Processing a single instruction is called an instruction cycle and consists of two primary stages: the Fetch Stage and the Execute Stage.
    • Program execution halts only under three conditions: processor power-down, an unrecoverable error, or an explicit halt instruction.
  • Fetch and Execute Mechanics:

    • At the beginning of each cycle, the processor fetches an instruction from memory.
    • The PC holds the memory address of the next instruction to fetch.
    • The processor automatically increments the PC after each fetch to point to the next sequential address in memory.
    • The fetched instruction is loaded into the IR.
    • The processor interprets the bit pattern inside the IR and performs the required operations.
  • Four Categories of Instruction Actions:

    1. Processor-Memory: Data transfer between processor and memory.
    2. Processor-I/O: Data transfer between processor and an I/O module (peripheral device).
    3. Data Processing: Execution of arithmetic or logic operations on data.
    4. Control: Alteration of the execution sequence (e.g., branch instructions).
    • An individual instruction execution cycle may involve a combination of these four actions.

Interrupts

  • Definition: An interrupt is a high-priority signal issued by hardware or software that requires the processor to suspend its current processing and execute the interrupt signal immediately.

Memory Hierarchy and Storage Devices

  • Key Parameters of Memory:

    • Capacity: The total amount of information or data a memory unit can store.
    • Access Time: The time interval between a read/write request and the actual availability of the data.
    • Organization Factors: Storage systems are organized in a hierarchy based on Speed, Cost, and Volatility.
  • Memory Hierarchy Levels (Top to Bottom):

    1. Registers: Fastest memory located inside the CPU. Extremely small capacity. Holds most frequently used data and instructions for arithmetic and logic operations.
    2. Cache Memory: Small, ultra-fast memory located close to the CPU. Copies frequently used data/instructions from RAM to reduce CPU access time. Available in levels L1, L2, and L3.
    3. Main Memory (RAM): Primary memory storing actively executing programs and data. Slower than cache, faster than secondary storage. Volatile in nature.
    4. Solid State Drive (SSD): Secondary storage using non-volatile flash memory. Lacks moving parts, making it fast, silent, and durable. Managed by an integrated controller.
    5. Magnetic Disk (Hard Disk Drive - HDD): Stores data on rotating magnetic platters logically divided into tracks and sectors. Provides large capacity at low cost, but is slower than SSDs due to mechanical moving parts.
    6. Optical Disk: Uses lasers to read and write data (e.g., CD, DVD, Blu-ray Disc). Portable with long storage life, used for media and backups.
    7. Magnetic Tape: Plastic tape coated with magnetic material. Offers low-cost, high-capacity archiving and backup; accesses data sequentially, making it slower than disk media.

Cache Memory Principles and Architecture

  • Operational Mechanism:

    • Volatile CPU-adjacent memory that holds active program code and temporary operational data.
    • Uses predictive algorithms based on past access history to determine the probability of which data will be needed next.
    • Main memory acts as a final cache layer for secondary storage.
  • Cache Levels Breakdown:

    • Level 1 (L1) Cache (Primary Cache):
      • Embedded directly within the microprocessor die.
      • Smallest capacity: ranges from 2 KB2\text{ KB} to 64 KB64\text{ KB}.
      • Primary target for initial processor instruction searches. Embedded registers include accumulator, address registers, program counter.
    • Level 2 (L2) Cache (Secondary Cache):
      • Located on the microprocessor.
      • More capacious than L1: ranges from 256 KB256\text{ KB} to 512 KB512\text{ KB}.
      • Accessed over a high-speed system bus if an instruction search misses in L1.
    • Level 3 (L3) Cache:
      • Larger capacity (1 MB1\text{ MB} to 8 MB8\text{ MB}) but slower than L1 and L2, yet operates at double the speed of RAM.
      • In multicore architectures, each core typically retains dedicated L1 and L2 caches while sharing a common L3 cache.
  • Trade-Offs:

    • Advantages: Dramatically faster than main memory, lower access time, speeds up temporary program execution.
    • Disadvantages: Very high financial cost and strictly limited storage capacity.

Direct Memory Access (DMA)

  • Concept: Allows an I/O device to transfer data directly to or from main memory without routing it through the CPU, eliminating CPU overhead during high-volume transfers. Managed by a Direct Memory Access Controller (DMAC).

  • Four Computer System Resource Tools:

    1. I/O addresses
    2. Memory addresses
    3. Interrupt request numbers (IRQ)
    4. Direct memory access (DMA) channels
  • I/O Execution Techniques: Programmed I/O, Interrupt-driven I/O, and Direct Memory Access (DMA).

Multiprocessor and Multicore Organization

  • Parallelism Drivers: Replicating hardware processors improves computational performance and enhances fault tolerance/reliability.

  • Three Popular Approaches to Processor Parallelism:

    1. Symmetric Multiprocessors (SMPs)
    2. Multicore Computers
    3. Clusters
  • Symmetric Multiprocessors (SMP):

    • Five Key Characteristics:
      1. Contains two or more similar processors of comparable capability.
      2. Processors share main memory and I/O facilities interconnected by a bus or shared link; memory access time is equal for all processors.
      3. Processors share access to I/O devices via common or distinct channels.
      4. All processors are capable of performing identical functions (symmetric).
      5. System controlled by an integrated OS facilitating core interactions at job, task, file, and data element levels.
    • SMP Advantages:
      • Performance: Enables execution of parallel work portions.
      • Availability: Failure of one CPU does not crash the machine; system continues at degraded capacity.
      • Incremental Growth: Users can scale processing capability by adding processor units.
      • Scaling: Allows vendor offerings across varied price/performance tiers.
    • SMP Architecture: Processors containing independent Control Units, ALUs, and registers connect to shared main memory and I/O through a shared bus. Processors communicate via shared address spaces or direct signaling.
  • Multicore Computers (Chip Multiprocessors):

    • Combines two or more processor units (cores) on a single piece of silicon (die).
    • Each core contains independent processor components: registers, ALU, pipeline hardware, control unit, and L1 instruction/data caches.
    • Case Study: Intel Core i7:
      • Contains four x86 processor cores, each with a dedicated L2 cache and a shared L3 cache.
      • Features an integrated DDR3 Memory Controller on chip, eliminating the traditional Front Side Bus (FSB).
      • Memory interface utilizes 33 channels, each 8 bytes8\text{ bytes} wide (total bus width of 192 bits192\text{ bits}), delivering up to 32 GB/s32\text{ GB/s} aggregate data rate.
      • Utilizes QuickPath Interconnect (QPI), a point-to-point electrical link operating at 6.4 GT/s6.4\text{ GT/s} (gigatransfers per second) for high-speed inter-chip communication.

Operating System Overview: Objectives and Functions

  • Definition: An Operating System (OS) is a software system that controls the execution of application programs and functions as an interface between application software and physical computer hardware.

  • Three Primary Objectives:

    1. Convenience: Makes a computer system easier and more user-friendly to operate.
    2. Efficiency: Allows hardware resources to be used optimally.
    3. Ability to Evolve: Permits modular development, testing, and deployment of new system functions without degrading existing services.
  • Core Operating System Functions:

    • Program Development: Provides facilities (editors, debuggers, utility software) categorized as application development tools.
    • Program Execution: Loads instructions and data into main memory, initializes hardware/files, and manages execution scheduling.
    • Access to I/O Devices: Standardizes access by abstracting device-specific control signals into uniform read/write calls.
    • Controlled Access to Files: Understands underlying storage media structures and enforces access/protection permissions in multi-user environments.
    • System Access: Manages access control for shared systems, protecting resources and resolving resource contention.
    • Error Detection and Response: Handles internal/external hardware errors (memory failures, device bugs) and software errors (division by zero, invalid memory access) with minimal application disruption.
    • Accounting: Collects resource utilization stats and performance metrics (e.g., response time) for system optimization and billing.

Evolution of Operating Systems

  1. Serial Processing (Late 1940s – Mid 1950s):

    • No operating system existed. Programmers interacted directly with hardware using physical punch cards/tapes and paper printers.
    • Problems: Manual scheduling caused wasted allocation time; setup time was excessive due to manual loading of compilers, source code, object code, libraries, and mounting tapes.
    • Drawbacks: Extremely low CPU utilization and zero automated job handling.
  2. Simple Batch Systems:

    • Introduced the first OS entity called the Monitor.
    • Users submitted jobs to a computer operator who grouped similar jobs into batches.
    • Resident Monitor: The core portion of the monitor permanently retained in main memory. Automates loading, starting, and ending sequential jobs.
    • Processor Operation: CPU alternates between executing monitor instructions (job loading/scheduling) and user program instructions.
  3. Multiprogrammed Batch Systems:

    • Uniprogramming Problem: The CPU is vastly faster than I/O devices. In uniprogramming, main memory holds only one program, forcing the CPU to remain idle whenever that program waits for I/O.
    • Multiprogramming Solution: Maintains multiple programs in memory simultaneously. When Program A pauses for I/O, the CPU immediately switches execution to Program B or C, maintaining high CPU usage.
  • Comparison: Batch Multiprogramming vs. Time Sharing:
    • Principal Objective: Maximize processor use (Batch) versus Minimize response time (Time Sharing).
    • Directive Source: Job Control Language (JCL) commands supplied with job (Batch) versus Commands entered directly at interactive terminals (Time Sharing).

Operating System Structures

  • Simple Structure:

    • Used in early OSs like MS-DOS and original UNIX.
    • Lacked clear structural boundaries; applications could directly access hardware and bypass OS interfaces.
    • Lacked dual execution modes (User Mode vs. Kernel Mode), meaning errors in application programs could crash the entire computer system.
  • Monolithic Approach:

    • All core functions (process management, memory allocation, file systems, device drivers) are packaged inside one unified kernel program.
    • Advantages: High execution speed because internal functions call each other directly within kernel address space.
    • Layered Approach Variant: Divides OS into hierarchical layers. Each layer communicates strictly with adjacent upper or lower layers. Highly modular, simple to debug, but suffers from performance degradation due to multi-layer routing overhead.
  • Microkernel Architecture:

    • Strips non-essential services out of the main kernel, keeping only minimal process management, basic memory management, and message passing facilities.
    • Subsystems run as user-space programs.
    • Benefits: Enhanced security, high reliability, and simple extensibility.
    • Drawback: High performance overhead caused by frequent message-passing context switches.

System Calls and Application Programming Interfaces (APIs)

  • System Calls: Interfacing primitives written in C, C++, or Assembly allowing running programs to request privileged kernel services.

  • Application Programming Interfaces (APIs):

    • Wrappers around system calls that simplify programming.
    • Benefits: Portability (code compiles across systems supporting the same API) and Ease of Use.
  • Three Methods for Passing Parameters to System Calls:

    1. Pass parameters directly inside processor registers.
    2. Store parameters in a memory block/table and pass the memory block's address in a register.
    3. Push parameters onto the system stack, where the OS pops them off.
  • Five Categories of System Calls:

    1. Process Control: Halting execution normally or abnormally, generating memory dumps for debuggers.
    2. File Management: Create, delete, read, write, reposition, close files, and get/set file attributes.
    3. Device Management: Request/release devices (physical like GPUs, or abstract like files), read, write, and reposition.
    4. Information Maintenance: Transfer system status metrics (time, date, process ownership) between OS and application.
    5. Communication: Interprocess communication via either the Message-Passing Model (using shared mailboxes) or the Shared Memory Model (mapping shared memory blocks for direct read/write access).

System Programs

  • System programs supply a convenient environment for software development and program execution, divided into seven functional categories:
    1. File Management: File/directory creation, deletion, copying, renaming, printing, dumping, and listing.
    2. Status Information: Reporting date, time, available disk/memory space, and active user metrics.
    3. File Modification: Text editors used to modify data on disks or tapes.
    4. Programming-Language Support: Bundled compilers, assemblers, and interpreters.
    5. Program Loading and Execution: Absolute loaders, relocatable loaders, linkage editors, and overlay loaders.
    6. Communications: Mechanisms to establish virtual connections between processes, users, and remote systems (e.g., Email, FTP, Remote Login).
    7. Application Programs: Tools for common user tasks (e.g., Web Browsers, Database Systems).

Operating System Generation (SYSGEN) and System Boot

  • System Generation (SYSGEN):

    • The specialized configuration step that tailors an OS image to a specific computer hardware configuration.
    • A SYSGEN program reads hardware parameters and compiles a customized target operating system kernel.
  • System Boot Process:

    1. Bootstrap Loader Execution: A small boot program initiates execution upon powering on.
    2. Hardware Diagnostics: Runs diagnostic tests (POST) to verify hardware sanity.
    3. Hardware Initialization: Initializes CPU registers, memory controllers, and peripheral devices.
    4. Kernel Loading: Locates the OS kernel, transfers it into main memory (RAM), and branches execution to the kernel entry point.
  • Firmware vs. Disk Boot Configurations:

    • Small Embedded Systems (Phones, Game Consoles): Entire OS is stored directly in non-volatile ROM/firmware.
    • Large Systems: Firmware holds only the initial bootstrap loader; the main OS kernel resides on a dedicated secondary boot disk.