Imprint | Privacy Policy

OS01: OS Introduction

Partially based on Chapter 1 of [Hai19]

(Usage hints for this presentation)

Computer Structures and Operating Systems 2023
Dr. Jens Lechtenbörger (License Information)

1. Introduction

1.1. Learning Objectives

  • Explain notion of Operating System and its goals
  • Explain notions and relationships of process, thread, multitasking

1.2. Recall: Big Picture of CSOS

  • Computer Structures and Operating Systems (CSOS)
    • CS: How to build a 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

    • OS: What abstractions do Operating Systems provide for applications?
      • Processes and threads with scheduling and concurrency, virtual memory

        Pong in TECS VM

        Pong in TECS VM” under GPLv2; screenshot of VM of TECS software suite

      • What is currently executing why and where, using what resources how?

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 [Hai19]: Software
    • that uses hardware resources of a computer system
    • to provide support for the execution of other software.

Figure 1.1 of cite:Hai17

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

2.2.1. Aside: API

2.2.2. OS Services

  • OS services/features/functionality defined by its API

    • Functionality includes
    • Support for multiple concurrent computations
      • Run programs, divide hardware, manage state
    • Control interactions between concurrent computations
      • E.g., locking, private memory
    • Typically, also networking support

Figure 1.1 of cite:Hai17

Figure 1.1 of [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 and later slide)
  • 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. User Space and Kernel Space

User space vs. kernel space

User space vs. kernel space

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

2.3.3. OS Size

  • From [TB15]
    • Size of source code of the heart Windows or GNU/Linux is about 5 million lines of code
      • Think of book with 50 lines per page, 1000 pages
      • Need 100 books or an entire bookcase
    • Windows with essential shared libraries is about 70 million lines of code
      • 10 to 20 bookcases
  • How to understand or maintain that?
    • → Abstraction, layering, modularization

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. OS Kernel

  • OS runs as code on CPU
    • Just as any other program
  • Kernel contains central part of OS
    • Provides API for OS services via system calls (next slide)
    • Code and data of kernel typically main memory resident
    • Kernel functionality runs in kernel mode of CPU, reacts to system calls and interrupts
    • Variants (previous slide)
      • Monolithic (“large,” all OS related services)
      • Micro kernel (“small,” only necessary services)
      • “Best” design subject to research
        • Provable security only with micro kernels (seL4)

2.4.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.4.3. Sample Microkernel: L4

  • L4, developed by Jochen Liedtke, late 1990s
  • Breakthrough result in 2009, [KEH+09]: Formal verification of the OS kernel seL4
    • Mathematical proof of correctness
      • Updates/patches are a thing of the past
    • More recent description in [KAE+14]
  • 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
    • Project Sparrow based on seL4

3. Multitasking

3.1. Multitasking

  • 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
      • Container for related threads and their resources
      • Created upon start of program and by programs (child processes)
      • 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 “applications” and processes
    • E.g., GNU Emacs provides lots of “applications”
      • 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)

3.4. Exercises and Self-Study Tasks

3.4.1. Processes and threads

This task is available for self-study in Learnweb.

  • 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 ;)

3.4.2. Exercise Outlook: Bash Command Line

  • Investigate The Command Line Murders among first OS exercises
    • 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)

3.4.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)

3.4.4. Feedback

  • This slide serves as reminder that I am happy to obtain and provide feedback for course topics and organization. If contents of presentations are confusing, you could describe your current understanding (which might allow us to identify misunderstandings), ask questions that allow us to help you, or suggest improvements (maybe on GitLab). Please use the session’s shared document or MoodleOverflow. Most questions turn out to be of general interest; please do not hesitate to ask and answer where others can benefit. If you created additional original content that might help others (e.g., a new exercise, an experiment, explanations concerning relationships with different courses, …), please share.

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
    • provides interface for applications and
    • manages resources.

Bibliography

License Information

This document is part of an Open Educational Resource (OER) course on Operating Systems. Source code and source files are available on GitLab under free licenses.

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

No warranties are given. The license may not give you all of the permissions necessary for your intended use.

In particular, trademark rights are not licensed under this license. Thus, rights concerning third party logos (e.g., on the title slide) and other (trade-) marks (e.g., “Creative Commons” itself) remain with their respective holders.