Biantian's Studio.

Operating System & Networking 01

Word count: 620Reading time: 3 min
2020/04/22 Share

Introduction to Operating Systems

1. What happens when a program runs?

  • It executes instructions.
  • Von Neumann model of computation


2. Making System Easy to Use

Body of Software: Operating System (OS)

Responsibility

  • Programs appear to run simultaneously.
  • Allowing program to share memory,
  • Enabling programs to interact with devices. I/O


1. Virtualization

  • The OS takes a physical resource (such as the processor, or memory, or a disk) and

  • Transforms it into a more general, powerful, and easy-to-use virtual form of itself.

    Thus, we sometimes refer to the operating system as a virtual machine

In order to allow users to tell the OS what to do:

  • make use of the features of virtual machine (such as running a program, or allocating memory, or accessing a file)

    • A typical OS provides APIs to do System Call.
    • An operating system provides a standard library to applications.

OS is a Resource Manager1

  • Virtualization allows many programs to run (Sharing the CPU)
  • Concurrent access to each program’s instruction and data (Sharing memory)
  • Many programs can access devices (Sharing disks)


2. Concurrency

An operating system needs to be a great juggler. Most noticeable in multi-threaded programs. A thread is like a function running within same memory space of other functions, with more than one active at a time.

3. Persistence

  • In system memory, data can be easily lost, as devices such as DRAM store values in a volatile manner; when power goes away or the system crashes, any data in memory is lost.
  • Thus, we need hardware and software to be able to store data persistently;
  • The hardware comes in the form of some kind of input/output or I/O device; in modern systems, a hard drive is a common repository for long-lived information.
  • The software in the operating system that usually manages the disk is called the file system.


OS Design Goals

  • Basic goal: abstraction

    Make system convenient and easy to use.

  • Provide high performance (minimize overheads).

  • Provide protection via isolation.

  • Ensure reliability.



OS: The Process

1. Overview

  1. The process: it is a running program.

  2. How to provide the illusion of many CPUs?

    OS creates this illusion by virtualizing the CPU. By running one process, then stopping it and running another, and so forth.

    Time sharing - run as many concurrent processes as desired (Cost = performance)

  3. Virtualization implementation

    Requirements: Low-level machinery (aka mechanisms) & High-level intelligence.

    1. Low-level machinery mechanisms

      mechanisms are low-level methods or protocols that implement a needed piece of functionality. For example, context switch, which gives the OS the ability to stop running one program and start running another on a given CPU (time-sharing mechanism).

    2. Intelligence (policies)

      A scheduling policy in the OS will make decision about which program should the OS run, likely using historical information, workload knowledge and performance metrics.

2. The Abstraction: A Process

1. Concept

Process consists of an inventory of different pieces of a system it accesses or affects during its execution.

Machine state: what a program can read or update when it is running, what parts of the machine are important to program execution?

2. Parts of a Process

  • Memory (aka address space)
  • Registers: hold the instructions
    • Program Counter (PC): tell which instruction of the program is currently being executed.
    • Stack pointer & frame pointer: manage the stack for function parameters, local variables and return addresses.
  • I/O information: include a list of the files the process currently has open.

3. Process API

  • Create

    An operating system must include some method to create new processes. What happens when you double click an app icon.

  • Destroy

    Interface to halt a runaway program

  • Wait

    Sometimes useful

  • Miscellaneous Control

    Suspend / resume


  1. Refer to the physical resource mentioned above. Processor == CPU

CATALOG
  1. 1. Introduction to Operating Systems
    1. 1.1. 1. What happens when a program runs?
    2. 1.2. 2. Making System Easy to Use
      1. 1.2.1. Body of Software: Operating System (OS)
        1. 1.2.1.1. Responsibility
        2. 1.2.1.2. 1. Virtualization
        3. 1.2.1.3. 2. Concurrency
        4. 1.2.1.4. 3. Persistence
        5. 1.2.1.5. OS Design Goals
  2. 2. OS: The Process
    1. 2.1. 1. Overview
    2. 2.2. 2. The Abstraction: A Process
      1. 2.2.1. 1. Concept
      2. 2.2.2. 2. Parts of a Process
    3. 2.3. 3. Process API