Imprint | Privacy Policy

OS01: OS Introduction

Partially based on Chapter 1 of [Hai17]

(Usage hints for this presentation)

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

DBIS Group
Prof. Dr. Gottfried Vossen
Chair for Computer Science
Dept. of Information Systems
WWU Münster, Germany

1 Introduction

1.1 Usage hints

1.2 Learning Objectives

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

1.3 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.3.1 OS Responsibilities

What does your OS even do?

What does your OS even do?

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

2 Operating Systems

2.1 Sample Modern Operating Systems

  • Different systems for different scenarios

2.2 Definition of Operating System

  • Definition from [Hai17]: 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)
    • GUI = process(es) using kernel functionality to handle (touch, keyboard, mouse) input, start programs, display output, …
      • Explorer for Windows
      • Various desktop environments for GNU/Linux
    • Command line = process using kernel functionality to handle (keyboard) input, start programs, display text output, …
    • 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

© 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

© 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

under CC0 1.0; from Wikimedia Commons

See this map of the Linux kernel for 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, 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
    • Liedtke’s 4th system (after Algol interpreter, Eumel, and L3)
    • Now with family of L4 based kernels
    • Notable properties
      • 12 KB source code
      • 7 system calls
      • Abstractions: Address space, Threads, Inter-Process-Communication (IPC)
  • 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 mobile phones
      • 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
      • A7 processor (iPhone 5S, iPad mini 3) and later
    • Airbus 350, Merkelphone

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
    • Frequently per second, 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
      • Unit of scheduling and concurrency
      • 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

3.2.1 Threads!

Threads!

Threads!

© 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?

© 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.:
  • 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
      • 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 JiTT Assignments

Work through the following tasks. Submit solutions in Learnweb.

3.4.1 Ticket to Exam

  • Solve 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
      • Or access on university server (Learnweb announcement)
    • Play game according to its README
    • While solving the case, you may want to see line no. 179 of some (large) text file
    • Submit commands to view line 179 of some text file, using head and tail, with short explanation
  • (Command line examples show up throughout this course; details of file handling to be revisited in presentation on processes)

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
    • Once on command line, maybe try this first:
      • ls (short for “list”) to view contents of current directory
      • 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.2 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
    • GNU/Linux kernel 1.3.56 dates back to 1996
    • Use educated guessing there ;)

3.4.3 BattleThreads

Prepare the in-class session by reading the instructions for the game BattleThreads. Everyone should read Sections 1–3.

If your last name starts with one of the letters from “A” to “K”, also read Section 4; otherwise, also read Section 5.

3.4.4 Feedback

  • What did you find difficult or confusing about the contents of the presentation? Please be as specific as possible. For example, 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). You may submit individual questions as response to this task or ask questions in our Riot room and the Learnweb forum. Most questions turn out to be of general interest; please do not hesitate to ask and answer in forum and Riot room. 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 In-Class Meeting

4.1 BattleThreads

  • Let’s play a variant of Battleship based on [HRB+03]
    • Our rules
    • Teams follow different rules
      1. Players of team = different processes
        • (Last names starting with “A” to “K”)
        • No shared data
        • Instead, explicit communication
      2. Players of team = threads within single process
        • (Last names starting with “L” to “Z”)
        • With shared data structure for game’s grid
    • Build teams
      • If last name starts with “A” to “K”, gather on right; otherwise, on left
      • Form teams of 4

5 Conclusions

5.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, this work, “OS01: OS Introduction”, is © 2017, 2018, 2019 by Jens Lechtenbörger, 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.