(73) Operating System Basics

Operating System Overview

  • Operating System (OS): A program that manages hardware and runs other applications.

  • Process: A running program, managed by the OS to prevent interference between processes.

  • System Calls: Interface for processes to interact with hardware through the OS.

Filesystem Management

  • The OS provides a file system to manage how processes read and write files.

  • User Interface: Allows users to run programs and manage files; common OS for PCs is Microsoft Windows.

    • Latest Versions: Windows 8 for clients, Windows Server 2012 for servers.

  • Unix Descendants: Linux and BSD are free, open-source, Unix-like operating systems; macOS is a proprietary system based on BSD.

Device Drivers

  • Device Driver: Module that manages a specific I/O device.

  • Generic Drivers vs. Specific Drivers:

    • Some devices can use generic drivers (e.g., USB mouse).

    • Others need specific drivers for full functionality (e.g., AMD Radeon graphics card).

Concurrency and CPU Cores

  • Modern OS allow multiple processes to run concurrently.

  • Each core can only execute one process at a time, interleaving OS tasks with processes.

  • Scheduler: Part of the OS that decides process execution time and workload management.

Preemptive Multitasking

  • Mechanism to manage running processes with interrupts.

  • Interrupt Handler: Saves the program state and invokes the scheduler to decide next actions.

  • Scheduler Algorithms:

    • Round-robin for equal time allocation.

    • More sophisticated algorithms consider process priority.

Memory Management

  • Process Memory: Each process has a separate memory allocation to prevent interference.

  • System Calls: Allow processes to request specific OS routines.

  • Privilege Levels: OS runs at a higher privilege than user processes to manage inputs/outputs.

  • Memory Space Structure:

    • Stack: Stores local variables and function calls; grows as needed.

    • Heap: Space for dynamic allocation, requires explicit requests to OS.

    • Text Section: Contains the code of the process, remains unchanged.

Managing Stack and Heap

  • Stack Overflow: Happens when too many recursive calls exceed allocated stack space, potentially leading to crashes.

  • Deallocation: Important to clear heap memory when no longer needed to avoid memory leaks.

Address Space Mapping

  • Each process has a unique address space, mapping to system memory through OS tables.

  • Pages: Fixed-size chunks of memory that the OS maps to actual RAM.

  • Swapping: Pages can be temporarily moved to storage if RAM is full, allowing processes to operate beyond RAM limits.

Process States

  • Lifecycle States:

    • Waiting: Awaiting scheduler selection.

    • Running: Actively executing.

    • Blocked: Waiting for external events (e.g., I/O operations).

    • Terminated: End of process lifecycle.

File System Abstraction

  • Presents data storage as directories and files to simplify data access for programs.

  • Partitioning: Drives can be divided into partitions, each formatted for file systems.

  • File Identification: Files within a directory are identified by unique IDs.

  • File Paths: Organization of files in directories with distinct syntax in Windows and Unix.

Interprocess Communication (IPC)

  • Mechanisms enabling processes to communicate with each other.

  • Examples include files, pipes, signals, and shared memory.

Summary

  • Understanding the OS's functions is crucial in managing processes, memory, and file systems. The OS ensures efficient resource usage and maintains system stability by regulating hardware access and process communication.