What is an Operating System?

Definition

Operating System: Program that runs on bare hardware to help bridge the gap between user and computer hardware.

Role & Goals

Role of the Operating System:

Goals of the Operating System:

Example: Hardware v.s. User Needs
ComponentCapabilitiesUser Needs
CPULow-level machine instructions.Arrays, lists, and other high-level data structures and operations.
Main memoryLinear sequence of addressable bytes / words.A heterogeneous collection of entities of various types and sizes, accessed by different operations.
Secondary storageMulti-dimensional structures that require complex sequences of low-level operations to store and access data organized in discrete blocks.Ability to access and manipulate programs and data without knowledge of disk organization.
I/O devicesOperated by reading and writing registers of the device controllers.Simple, uniform interfaces to access different devices without detailed knowledge of the access and communication protocols.

Core OS Concepts

Abstraction and Virtualization

Abstraction: Act of removing unimportant details or attributes of objects to make more general and less complex objects.

Example: Abstraction at the Programmer and User Level

User Abstraction: “Copy file f1 to file f2”

OS:

  1. Create file f2
  2. Open file f1 for reading
  3. Repeat for all blocks i of f1:
  4. Read block i into memory buffer
  5. Allocate new block j for file f2
  6. Write memory buffer to block j

Programmer Abstraction: “Read block n into memory at location m

OS:

  1. Compute block location on disk
  2. Move read/write arm into position.
  3. Check for positioning errors.
  4. Transfer data to memory starting at m.
  5. Check for read errors.

Virtualization: Act of creating the illusion of having one or more objects with more desirable properties than the real object.

Example: Virtual memory

Virtual memory creates the illusion that each program has access to a large, contiguous address space, even though the actual physical memory may be fragmented, shared with other programs, or partially stored on disk.

OS Conceptual Roles

From a system perspective, the OS can be viewed in two key roles:

  1. OS as a resource allocator:
  2. OS as a control program:

Computer System Structure

Four Components of a Computer System

  1. User
  2. System & Application
  3. Operating System
  4. Hardware

System Startup & Organization

Bootstrap Program: Firmware that initializes all aspects of system.

System Bus: Device controllers connect through common bus providing access to shared memory.

System Operations

Device Controller:

Example: Starting an I/O operation
System Call RoutinesDevice DriverApplicationDevice ControllerHardware
  1. Device driver loads appropriate registers within the device controller
  2. Device controller examines contents of these registers to determine what action to take
  1. Controller starts transfer of data from device to local buffer.
  2. Once transfer completes, device controller informs device drivers via interrupt it is finished.
  3. Device driver returns control to OS.

Note — We can use DMA to speed this up.

Storage Subsystem

Storage Structure

CPU can load instructions only from memory.

Storage Hierarchy

Ordered fastest to slowest and most expensive to cheapest:

  1. Registers
  2. Cache
  3. Main Memory
  4. SSD
  5. HDD
  6. Optical Disk
  7. Magnetic Tapes

Note: 1—3 are volatile, 4—7 are non-volatile.

Caching

Cache: Information in use copied from slower to faster storage temporarily.

Recall — The guiding principle of “smaller is faster”. This is why CPUs have layers of cache. (Related Notes: “CPU”, from CS3650)

Direct Memory Access (DMA)

Used for high speed I/O devices so that can transmit information at close to memory speeds.

Hardware Architecture

Many years ago, most systems only had one general-purpose processor (one CPU with a single processing core).

Multiprocessor: Growing in use and importance.

Two Types of Multiprocessors

Dual Core: Multiple cores on a single chip ends up more efficient than multiple single-core chips.

Clustered Systems: Like multiprocessor, but it’s multiple systems instead.

Two Types of Clustered Systems:

Major Operating System Functions

Process Management

Process Management: Provide process abstraction, and manage processes with CPU scheduling.

Reminder: Definitions

Multiprogramming: Technique that keeps several programs active in memory and switches execution among different programs to maximize the use of the CPU and other resources.

Time-Sharing (Multitasking): Extension of multiprogramming where the CPU is switched periodically among all active computations to guarantee acceptable response times.

Example: More on I/O and CPU-Bound instructions

Suppose the following:

cpu-bound instruction 1
cpu-bound instruction 2
cpu-bound instruction 3
print(4)
cpu-bound instruction 5

print, in this example, is I/O bound (need to do the slow task of communicating to a peripheral to print).

Multiprogramming: When we hit print, we context switch to a separate process so CPU can stay busy with other CPU-bound instructions. Once the I/O bound portion is done, we signal we are done via interrupt, and the CPU will get back to us.

Time-Sharing: Imagine a timer on a process. When that timer runs out, the CPU will context switch to a different process and the process will have to wait for its turn.

Sequential: Run through processes sequentially. CPU simply waits through I/O instructions.

Example: Comparing Sequential, Multiprogramming, and Timesharing

Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O bound phase of 10 units.

Sequential: 40 TU

CPUAB
IO 1A
IO 2B

Multiprogramming: 30 TU

CPUAB
IO 1A
IO 2B

Timesharing: 20 TU (if context switching is negligible)

CPUABAB
IO 1A
IO 2B

Memory Management

Share memory among processes, safely.

Storage (Disk) Management

Provide file abstraction, manage files.

I/O Control and Mangement

Device drivers, buffering, providing uniform access interface.

Protection and Security

Control access to resources, prevent interference with OS and other processes.

OS Context and Scope

Perspectives on OS Goals

Depends on POV.

User View:

Computing Environments

Traditional

We are used to standalone general-purpose machines.

Distributed

Collection of separate, possibly heterogeneous, systems networked together.

Common Network Types:

Relevant Notes: Intro to Cyber Security and Network Communications

Cloud

Deliver computing, storage, and/or apps as a service across a network.

Major Types:

  1. Public: Available to anyone willing to pay
  2. Private: Run by a company for internal use.
  3. Hybrid: Includes public and private cloud components.

Service Types:

Real-Time Embedded Systems

Special/limited purpose computers.

Examples: Embedded systems

Open Source Operating Systems

Made available in source-code rather than just binary closed-source.

Examples: Open Source OSes

Kernel

Kernel: “The one program running at all times on the computer”

On Course Scope: For this class, we don’t care about:


  1. One might say that this is an embedded embedded system…↩︎