Fundamentals of Operating Systems

Jul 14, 2024

Fundamentals of Operating Systems

Introduction

  • Definition and Importance:
    • Provides abstraction and arbitration.
    • Abstraction hides hardware details; arbitration manages access to shared resources.
  • Key Components Managed:
    • CPU, memory hierarchy, input/output devices, power, and system management.
    • Involved in energy conservation.

Abstraction

  • Definition: Hiding hardware differences to provide a uniform interface for applications.
  • Example from the 1990s: Games required specific configurations for video and sound cards.
  • Abstraction's Advantage: Allows hardware variety without needing separate software for each device.
  • Modern Example: Switching between Intel and AMD processors without needing separate applications.

Arbitration

  • Definition: Managing access to shared hardware so multiple applications can run concurrently without interference.
  • Examples:
    • Switching between applications (CPU management).
    • Memory allocation.
    • Isolating applications to prevent system crashes.

Applications of Abstraction and Arbitration

  • Support for multiple CPUs and intelligent resource management.
  • Enabling applications to use different hardware devices (e.g., webcams, hard disks) without unique code for each.

System Layers

  • Layer Cake Model:
    • Bottom: Hardware
    • Middle: Operating System (OS)
    • Top: Applications and Libraries
  • Kernel: Core part of the OS, everything outside is user space.
  • OS Functions: Managing access and sharing hardware resources (system calls and interrupts).

Types of Operating Systems

  • Microsoft Windows:
    • Pre-installed on PCs, most popular desktop OS.
    • Being surpassed by tablets running Unix-like systems.
  • Unix-like Systems:
    • Includes BSD, Mac OS X, Linux (and Android).
    • Multi-user, based on Multics (1969) by Bell Labs.
  • Real-time, mainframe, embedded OS examples.

Memory Hierarchy in Systems

  • Components:
    • CPU registers, cache, random access memory (RAM), persistent storage (disks, SSDs).
  • Form Factors:
    • ATX, microATX, miniATX for desktops and workstations, rack-mounted servers for data centers.

Persistent Storage

  • Hard Disk Drives (HDDs): Mechanical, magnetic storage, subject to seek time and rotational delay.
  • Solid State Drives (SSDs): Faster, use flash memory, limited write cycles (wear leveling management).

Backups

  • Importance of backing up data to prevent loss.
  • Types of Backup Media:
    • Optical Disks (CDs, DVDs, Blu-ray), Flash Drives, Tape Drives, Cloud Storage.

Disk Scheduling

  • Purpose: Managing disk I/O to improve performance.
  • Classical Algorithms: First-come-first-serve, elevator algorithms (scan, look, C-scan, C-look), shortest seek time first (obsolete with modern drives).
  • Modern Considerations: Native Command Queuing (NCQ) for internal disk scheduling.

Software Development Cycles

  • Steps: Planning, requirements analysis, design, coding, testing, deployment, maintenance.
  • Development Models: Code-and-Fix, Waterfall, Iterative-Incremental (Agile, Rapid Application Development, Extreme Programming).
  • Formal Methods: Required for life/safety-critical systems (e.g., cleanroom engineering).

File Systems

  • Purpose: Laying out data on persistent storage, storing metadata, ensuring reliable data retrieval.
  • Issues: Fragmentation (internal, external), Journaling.
  • Layouts: File Allocation Table (FAT), inodes, extents.

Requirements Analysis

  • Types of Projects: Greenfield vs. Re-engineering.
  • Key Roles: Stakeholders, interests, primary and supporting actors.
  • Requirements Types: Functional (what the system does), Non-functional (quality attributes, what the system is).

CPU and Multi-Programming

  • Multi-programming: Running multiple processes concurrently by CPU switching.
  • Hardware Requirements: Interrupts, CPU protection levels (kernel/user mode), mode switches.

Kernel Architectures

  • Functions of the Kernel: Abstraction, arbitration, ensuring system stability and performance.
  • Types: Monolithic (e.g., Linux, Windows NT), Microkernels (e.g., L4, Mach).
  • Hybrid Designs: Combine features of both for performance and modularity.

Unified Modeling Language (UML)

  • Purpose: Standardized way to model software designs (classes, behaviors, interactions).
  • Types of Diagrams: Structural (class diagrams), Behavioral (activity, state machine), Interaction.

Memory Allocation

  • Dynamic: Allocating memory as needed to prevent space wastage and handle high multiprogramming.
  • Methods: Power of two, buddy system, slab allocation (for kernels).

Process Management

  • Process Contexts: Information needed to stop and restart a process (CPU registers, program counter, memory contents).
  • States: New, ready, running, waiting, terminated.
  • Scheduling: Job (long-term), Midterm, and Short-term (CPU) scheduling.
  • Process Control Blocks (PCBs): Arrays and linked lists managing processes' state information.

Conclusion and Key Takeaways

  • Operating systems are essential for managing hardware resources and providing a uniform interface for applications.
  • Abstraction and arbitration are fundamental to managing the diverse and concurrent needs of applications and hardware.
  • Comprehensive understanding of OS functions, different kernel types, and effective memory and process management techniques is crucial for designing and maintaining robust, efficient computer systems.