OS: run programs, share memories & interact with devices

refer to the OS as a virtual machine

System call

Tells OS what to do. Standard libs and APIs.

Resource management

OS manages CPU, memory and disk, and share them among programs.

CPU virtualization

Turn some physical CPUs into seemingly infinite virtual CPUs, and thus allow programs to run at once.

Mem virtualization

Physical memory is an array of bytes (1 dimension).

Read mem - load; write mem - store

Memory of each running program seems to be allocated at the same address (00200000), but actually not.

The memory parts are separated and a program cannot access memory of other programs.

See Zhihu.

Concurrency 并发

Concurrency is “pretending” running multi programs/threads at the same time.

Concurrency is not parallel, which is really running together.

Fig 2.5 a multithread program: two threads may load the counter from mem to reg at the same time, and store back together. As a result, the counter is only added once.

Persistence 持久性,一致性

RAM loses data easily, but storing data persistently is needed.