Operating System Functions and Components

Program Execution

  • Operating System (OS) furnishes a complete execution environment so that a user program can be loaded, started, and run to completion.

    • Program image is loaded from secondary storage into main memory (RAM).
    • The CPU is assigned to the newly created process, beginning at the program’s entry point.
    • While the program is running, the OS remains in supervisory control, ready to step in whenever an interrupt, trap, or system call occurs.
  • Ancillary responsibilities tied to execution:

    • Memory Allocation / De-allocation:
      • Allocate the exact amount of memory a process requests (heap, stack, code, and data segments).
      • Reclaim that space once the process terminates.
    • Process Scheduling:
      • Decide which ready process gets the CPU next.
      • Employ algorithms such as First-Come-First-Serve, Round-Robin, or \text{O}(1) multi-level feedback queues (mentioned conceptually—even if the transcript did not cite them, they are the canonical examples).
    • Normal vs. Abnormal Termination:
      • Normal – program reaches an orderly \texttt{exit()}, returns control to the OS.
      • Abnormal – OS must intervene on illegal memory access, divide-by-zero, or explicit user kill.

I/O Operations

  • Motivation: A running program often needs to interact with external entities – e.g., display results, fetch input, or send a print job.
  • Indirection & Protection:
    • User processes cannot manipulate hardware registers directly; doing so would jeopardize system integrity.
    • OS exposes a higher-level, safer interface: system calls such as \texttt{read()}, \texttt{write()}, \texttt{open()}, \texttt{close()}, \texttt{ioctl()}.
  • Examples enumerated in transcript:
    • Sending a document to a printer.
    • Reading from / writing to a file.
  • Efficiency mechanisms (implied):
    • Buffering & caching.
    • Interrupt-driven vs. polling strategies.
    • Direct Memory Access (DMA) to offload byte transfers from CPU.

File-System Manipulation

  • Secondary-Storage Management: OS maintains a persistent hierarchy of files and directories on disks, SSDs, or network volumes.
  • User / Program Operations that require OS mediation:
    • Open / create a file.
    • Read sequentially or at random offsets.
    • Write / append / truncate.
    • Delete, rename, or change permissions.
  • Typical Command Flow (as implied):
    1. User issues a shell command or the program invokes a library function.
    2. Library traps into the kernel, initiating the requested file operation.
    3. OS consults metadata (inodes, FAT entries, etc.), checks permissions, and executes the operation.
  • Consistency & Safety Guarantees: journals, copy-on-write snapshots, or logging ensure that crashes do not corrupt the file system.

Cross-Cutting Themes & Significance

  • Resource Abstraction: All three areas (execution, I/O, file systems) hide hardware specifics behind a uniform API, raising programmer productivity.
  • Protection Domains: By mediating every access, the OS protects users from each other and from the hardware.
  • Performance vs. Safety Trade-off:
    • Too much checking slows execution; too little invites crashes or security holes.
    • Modern kernels strive for balanced designs—e.g., zero-copy I/O to reduce overhead while still enforcing access control.
  • Real-World Relevance: Cloud platforms, smartphones, and embedded controllers rely on the same core OS services described above.

Connections to Broader Course Content

  • Builds upon prior lectures on Process States (new, ready, running, waiting, terminated).
  • Anticipates future topics: Virtual Memory, Synchronization Primitives (semaphores, mutexes), and Deadlock Handling.
  • Echoes foundational principle: the OS is the "manager of resources"—CPU cycles, memory cells, I/O channels, and disk blocks.