Operating Systems: Introduction
Introduction
Computer Systems: Three Easy Pieces
Virtualization: the OS takes a physical resource and transforms it into a more general, powerful, and easy-to-use virtual form of itself. Thus, the OS is sometimes referred to as a virtual machine.
A typical OS exports a few hundred system calls that are available to applications. The OS provides a standard library to applications.
The OS is sometimes known as a resource manager for CPU, memory, and disk.
Virtualizing
1 |
|
1 | gcc -o cpu cpu.c -Wall # -Wall 打开警告 |
1 | ./cpu A & ./cpu B & ./cpu C & ./cpu D & |
Virtualizing the CPU
Policy of the OS.
1 |
|
1 | ./mem &; ./mem & |
Virtualizing memory: each process accesses its own private virtual address space.
Concurrency
1 |
|
Concurrency and multi-threaded
1 | gcc -o thread thread.c -Wall -pthread |
Instructions do not execute atomically (all at once)!
Persistence
DRAM store values in a volatile manner, therefore we need hardware and software to be able to store data persistently.
- Hardware: I/O device: hard drive, solid-state drives
- Software: file system
1 |
|
Device driver
The OS provides a standard and simple way to access devices through its system calls. Thus, the OS is sometimes seen as a standard library.
For performance reasons, most file systems first delay such writes for a while, hoping to batch them into larger groups. To handle the problems of system crashes during writes, most file systems incorporate some kind of intricate write protocol, such as journaling or copy-on-write, carefully ordering writes to disk to ensure that if a failure occurs during the write sequence, the system can recover to reasonable state afterwards.
Design Goals
Build up some abstractions in order to make the system convenient and easy to use.
High performance and Minimize the overheads of the OS.
Provide protection between applications, as well as between the OS and applications. Isolation is the heart of one of the main principles underlying an operating system.
A high degree of reliability is required.
Other goals include energy-efficiency, security, mobility.