0%

Operating Systems: Three Easy Pieces阅读笔记(一) Introduction

1. Operating System

(1) Definition

Operating system is a body of software which is responsible for making sure the system operates correctly and efficiently in an easy-to-use manner. Operating system acchieve this goal through a general techenique that we call virtualization.

(2) Responsibility of the OS

Make it easy to run programs, allow programs to share memory, enable programs to interact with diveces,.etc.

(3) Four Themes of This Book

  1. Virtualization
  2. Concurrency
  3. Persistence
  4. Security

2. Virtualzition

(1) Definition

Transform physical resources into a more general, powerful and easy-to-use virtual form of itself.

(2) Virtualizing The CPU

Turning a single CPU into a seemingly infinite number of CPUs and thus allowing many programs to seemingly run at the same time

(3) Virtualizing The Memory

Each process accesses its own private virtual address space, which the OS somehow maps onto the physical address of the machine.

Note: Physical Memory Model

Memory is just an array of bytes; to read memory, one must specify an address to be access the data stored there; to write memory, one must specify the data to be written to the given address.

3. Concurrency

(1) Definition

A host of problems that arise when working on many things at onces in the same program.

(2) Senario

Use two threads to increment a shared variable in a loop. As the number of interation set to 1000, the final value is 2000 as expected. When the number of iteraction set to 100000, the correct answer is not guaranteed.

(3) Cause

The increment process takes 3 instructions: load the value of the vairable from memory into a register, increment, store it back to memory. These instructions do not execute atomically.

4. Persistence

(1) File System

File System is responsible for storing any files the user creates in a reliable and efficient manner on the disk of the system.

(2) Standard Library

OS provides uniform library to make it easy to access devices through system calls.

(3) Performance Optimization

Most file system delay writes for a while, hoping to batch them to a larger group.

(4) Reliability Opimization

To handle the problems of system crashes during writes, most file system incorporate some kind of intricate write protocol like copy-on-write to ensure that if failure occurs during writing sequence, the system can recover to a reasonable state afterwards.

5. Design Goals of Operating System

  • Abstraction
  • Minimize the overhead
  • Protection between application(Isolation)
  • Reliability
  • Security
  • Mobility
  • Energy-efficiency