Imprint | Privacy Policy

OS Introduction

(Usage hints for this presentation)

IT Systems, Summer Term 2024
Dr. Jens Lechtenbörger (License Information)

1. Introduction

1.1. Learning Objectives

  • Explain notion of Operating System and typical services
    • Explain notion of kernel with system call API, user mode and kernel mode
  • Explain notions and relationships of program, process, thread, multitasking
  • Use the Bash command line: Navigate in directories, view lines of files, search for patterns, use redirection and pipelines

1.2. Recall: Big Picture of IT Systems

  • Explore abstractions bottom-up

    • Computer Architecture: Build computer from logic gates

      NAND

      NAND” under CC0 1.0; from GitLab

      • Von Neumann architecture
      • CPU (ALU), RAM, I/O

        CPU

        CPU” under CC0 1.0; cropped and converted from Pixabay

    • Experiment with OS concepts
      • Explain core OS management concepts, e.g., processes, threads, virtual memory
      • Use GNU/Linux command line and explore system

        Tux, the Linux mascot

        Tux, the Linux mascot” under CC0 1.0; from Wikimedia Commons

    • Experiment with containerization for cloud infrastructures

1.2.1. OS Responsibilities

What does your OS even do?

What does your OS even do?

Figure © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.

2. Operating Systems

2.1. Sample Modern Operating Systems

2.2. Definition of Operating System

  • Definition from (Hailperin 2019): Software
    • that uses hardware resources of a computer system
    • to provide support for the execution of other software.
  • Towards these goals, OS provides API with services

Figure 1.1 of cite:Hai17

Figure 1.1 of cite:Hai17” by Max Hailperin under CC BY-SA 3.0; converted from GitHub

2.2.1. Aside: API

  • API = Application Programming Interface
    • Set of functions or interfaces or protocols defining how to use some system (as programmer)
      • E.g., Java 18 API
        • Packages with classes, interfaces, methods, etc.
    • OS kernel provides system call interface for its services

2.2.2. OS Services

  • OS services/features/functionality defined by its API
    • Functionalities include:

      • Support for multiple concurrent computations

        • Run applications, divide hardware, manage state
      • Control interactions between concurrent computations

        • E.g., locking, private memory
      • Files for persistent storage and interaction

      • Typically, also networking support

Figure 1.1 of cite:Hai17

Figure 1.1 of cite:Hai17” by Max Hailperin under CC BY-SA 3.0; converted from GitHub

2.3. OS, Kernel, User Interface

  • Boundary between OS and applications is fuzzy

  • Kernel is fundamental, core part of OS

    • Kernel defines API and services via system call interface
    • More details on next slides and in next presentation
  • User interface (UI; not part of kernel)

    • UI = process(es) using kernel functionality to handle user input, start programs, produce output, …
      • User input: Voice, touch, keyboard, mouse, etc.
      • Typical UIs: Command line, explorer for Windows, various desktop environments for GNU/Linux, virtual assistants
    • Note: OSs for embedded systems may not have UI at all

2.3.1. How to Talk to OSs

How to talk to your operating system

How to talk to your operating system

Figure © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.

2.3.2. System Calls

  • System call = function = part of kernel API
    • Implementation of OS service
      • E.g., process execution, main memory allocation, hardware resource access (e.g., keyboard, network, file and disk, graphics card)
  • Different OSs offer different system calls (i.e., offer incompatible APIs)
    • With different implementations
    • With different calling conventions

2.3.3. User Space and Kernel Space

  • CPU has privilege levels/rings/modes
    • Machine instruction set restricted depending on level

      User space vs. kernel space

      User space vs. kernel space” © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.

      • E.g., 4 rings since Intel 80286
      • Ring 3: User mode for programs
        • I/O and memory access restricted
      • Ring 2, 1: Usually unused
        • Originally for system services and device drivers
      • Ring 0: Kernel mode for OS
        • Traditionally, most privileged
        • (See here for negative ring numbers)

2.4. OS Architecture and Kernel Variants

Monolith-, Micro- and a

Monolith-, Micro- and a "hybrid" kernel

Figure under CC0 1.0; from Wikimedia Commons

This map of the Linux kernel provides a real-life monolithic example

2.4.1. Sample Microkernel: L4

  • L4, developed by Jochen Liedtke, late 1990s
  • Breakthrough result in 2009, (Klein et al. 2009)
    • Formal verification of the OS kernel seL4
      • Mathematical proof of correctness
        • Updates/patches are a thing of the past
      • More recent description in (Klein et al. 2014)
  • L4 variants today
    • OKL4, deployed in over 2 billion devices
      • OS for baseband processor (modem, management of radio functions)
        • Starting with Qualcomm
      • Embedded, mobile, IoT, automotive, defense, medical, industrial, and enterprise applications
    • Another variant in Apple’s Secure Enclave coprocessor (see PDF on this page)
      • A7 processor (iPhone 5S, iPad mini 3) and later
    • Airbus 350, Merkelphone

3. Multitasking

3.1. Multitasking Terminology

  • Fundamental OS service: Multitasking

    • Manage multiple computations going on at the same time
    • E.g., surf on Web while Java project is built and music plays
  • OS supports multitasking via scheduling

    • Decide what computation to execute when on what CPU core
      • Recall: Frequently per second, time-sliced, beyond human perception
  • Multitasking introduces concurrency

3.2. Computations

  • Various technical terms for “computations”: Jobs, tasks, processes, threads, …

    • We use only thread and process
    • Process

      • Created upon start of program and by programs (child processes)
      • Container for related threads and their resources
      • Unit of management and protection (threads from different processes are isolated from another)
    • Thread

      • Sequence of instructions (to be executed on CPU core)
      • Single process may contain just one or several threads, e.g.:
        • Online game: different threads with different code for game AI, GUI events, network handling
        • Web server handling requests from different clients in different threads sharing same code
      • Unit of scheduling and concurrency

3.2.1. Threads!

Threads!

Threads!

Figure © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.

3.2.2. Process Aspects (1/3)

What's in a process?

What's in a process?

Figure © 2016 Julia Evans, all rights reserved; from julia's drawings. Displayed here with personal permission.

3.2.3. Process Aspects (2/3)

  • Approximately, process ≈ running program
    • E.g., text editor, game, audio player
    • OS manages lots of them simultaneously
  • Really, process = “whatever your OS manages as such”
    • OS specific tools to inspect processes (research on your own!)

3.2.4. Process Aspects (3/3)

  • Single program may create multiple processes, e.g.:

    • Apache Web server with “process per request” (MPM prefork)
    • Web browsers with “process per tab” or separation of UI and web content
  • Many-to-many relationship between “programs” and processes

    • E.g., GNU Emacs provides lots of “programs”
      • Core process includes: Text editor, chat/mail/news/RSS clients, Web browser, calendar
        • Neal Stephenson, 1999: “emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish.”
      • On-demand child processes: Spell checker, compilers, PDF viewer

3.3. Processes vs Threads

Classification of Processes and Threads from Anderson et al. (1997)

Classification of Processes and Threads from Anderson et al. (1997)

4. Conclusions

4.1. Summary

  • OS is software
    • that uses hardware resources of a computer system
    • to provide support for the execution of other software.
      • Computations are performed by threads.
      • Threads are grouped into processes.
  • OS kernel
    • runs in kernel mode of CPU,
    • provides interface for applications, and
    • manages resources.
  • Micro kernels allow for correctness proofs.

4.2. Exercises and Self-Study Tasks

4.2.1. Processes and threads

  • Hack, MS-DOS, Java Virtual Machine, Windows 10, GNU/Linux, GNU/Linux prior kernel 1.3.56, GNU/Linux starting with kernel 1.3.56
    • It is no problem if you do not know those environments and guess for this task
    • MS-DOS dates back to the 1980s, the GNU/Linux kernel 1.3.56 to 1996
      • Use educated guessing there ;)

4.2.2. Study Work: Bash Command Line

  • Investigate The Command Line Murders
    • Game, which teaches use of the Bash command line
    • Command line = shell = text-mode user interface for OS
      • Create processes for programs or scripts
    • Different shells come with incompatible features
  • Task
    • Access files for game
      • Download or clone with git clone https://github.com/veltman/clmystery.git
    • Start playing game according to its README
    • While investigating the case, you need to search files for clues, learning essential commands and patterns along the way
    • We will ask you to submit some command(s)
  • (Command line examples show up throughout this course; details of file handling to be revisited in presentation on processes)

4.2.3. Using Bash as Command Line

  • Where/how to start Bash as command line
  • Basic hints for The Command Line Murders
    • Game’s cheatsheet is misnamed; it contains essential information to get you started
      • Open in editor
    • Once on command line, maybe try this first:
      • mount to show filesystems, e.g., with Cygwin, the location of C: may be shown as /cygdrive/c
      • ls (short for “list”) to view contents of current directory
      • ls /cygdrive/c to view contents of given directory (if it exists)
      • Beware! Avoid spaces in names of files and directories: Space character separates arguments (need to escape spaces with backslash or use quotation marks around name)
      • pwd (short for “print working directory”) to print name of current directory
      • cd replace-this-with-name-of-directory-of-mystery (short for “change directory”) to change directory to chosen location, e.g., location of mystery’s files
      • man name-of-command shows manual page for name-of-command
      • Try man man first, then man ls
    • Afterwards, follow game’s README
      • (Which supposes that you changed to the directory with the game’s files already)

Bibliography

Hailperin, Max. 2019. Operating Systems and Middleware – Supporting Controlled Interaction. revised edition 1.3.1. https://gustavus.edu/mcs/max/os-book/.
Klein, Gerwin, June Andronick, Kevin Elphinstone, Toby Murray, Thomas Sewell, Rafal Kolanski, and Gernot Heiser. 2014. “Comprehensive Formal Verification of an Os Microkernel.” Acm Trans. Comput. Syst. 32 (1): 2:1–2:70. https://doi.org/10.1145/2560537.
Klein, Gerwin, Kevin Elphinstone, Gernot Heiser, June Andronick, David Cock, Philip Derrin, Dhammika Elkaduwe, et al. 2009. “seL4: Formal Verification of an OS Kernel.” In Proceedings of the Acm Sigops 22nd Symposium on Operating Systems Principles, 207–20. Sosp ’09. Big Sky, Montana, USA: ACM. https://doi.org/10.1145/1629575.1629596.

License Information

Source files are available on GitLab (check out embedded submodules) under free licenses. Icons of custom controls are by @fontawesome, released under CC BY 4.0.

Except where otherwise noted, the work “OS Introduction”, © 2017-2024 Jens Lechtenbörger, is published under the Creative Commons license CC BY-SA 4.0.