Modern Operating Systems 笔记 - Linux

操作系统 Unix Linux GNU Socket

History of Unix and Linux

MULTICS & UNICS

  • Researchers at M.I.T. joined forces with Bell Labs and Generic Electric and began designing a second-generation system, MULTICS(Multiplexed Information and Computing Service)
  • One of the Bell Labs researchers, Ken Thompson wrote a stripped-down MULTICS on a PDP-7 minicomputer. The system is called UNICS(UNiplexed Information and Computing Service) jokingly by Brian Kernighan, Bell Labs.
  • Thompson tied to rewite UNIX with B language of his own design and failed. Ritchie then designed a successor to B, called C. Working together, they rewrote UNIX in C.
  • Steve Johnson of Bell Labs designed and implemented the portable C compiler, which could be retargeted to produce code for any resonable machine with a only a moderate amount of effort.

Standard UNIX

  • AT&T released its first commercial UNIX: System III, then System V.
  • Aided by U.S. Dept. of Defense, Berkeley released an improved PDP-11 called 1BSD(First Berkeley Software Distribution), which supported virtual memory, TCP/IP, vi, csh, etc.
  • IEEE came up with POSIX(Portable Operating System of UNIXish), witch reconcile the two flavors of UNIX.

Modern Operating Systems 笔记 - File System

操作系统 文件系统

Files

File structures

Byte sequence , Record sequence , Tree

File Types

Regular files , Directories , Character special files , Block special files

File operations

Create , Delete , Open , Close , Read , Write , Append , Seek , Get attributes , Set attributes , Rename.

Makefile 入门

Bash C++ Makefile Unix Windows sed 引用 汇编 编译 进程 字符串 操作系统

make是软件开发中常用的工具程序(Utility software),常被用来构建C程序。make通过读取叫做“makefile”的文件,来自动化建构软件。

虽然make常被用来构建C程序,但它可用于绝大多数的文件处理过程。例如,更新一批图片的缩略图: http://harttle.github.io/2013/10/26/auto-thumb/

它是一种转化文件形式的工具,转换的目标称为“target”; 与此同时,它也检查文件的依赖关系,如果需要的话,它会调用一些外部软件来完成任务。 它的依赖关系检查系统非常简单,主要根据依赖文件的修改时间进行判断。 大多数情况下,它被用来编译源代码,生成结果代码,然后把结果代码连接起来生成可执行文件或者库文件。 它使用叫做Makefile的文件来确定一个target文件的依赖关系,然后把生成这个target的相关命令传给shell去执行。

中文Tutorial

Modern Operating Systems 笔记 - Input/Output

操作系统 DMA 内存映射 中断 Unix

Principles of I/O Hardware

Devices & Controllers

  • block devices stores information in fixed-size blocks, each one with its own address.
  • character devices delivers or accepts a stream of characters, without regard to any block structure.
  • device controller/adapter takes the form of a chip on the parentboard or a printed circuit card that can be inserted into a (PCI) expansion slot.

Memory-Mapped I/O

Each control register is assigned a unique memory address to which no memory is assigned.

Pros:

  • if special I/O instructions are needed to read/write the device control registers, access to them requires nothing more than standard C code, otherwise needs the use of addembly code.
  • with memory-mapped I/O, no special protection mechanism is needed to keep user processes from performing I/O.
  • With memory-mapped I/O, every instruction that can reference memory can also reference control registers.

Cons:

  • most computers nowadays have some form of caching of memory words. Caching a device control register would be disastrous.
  • If there is only one address space, then all memory modules and all I/O devices must examine all memory references to see which ones to respond to.

Modern Operating Systems 笔记 - Memory Management

操作系统 虚拟内存 页表 LTB

No Memory Abstraction

Running multiple programs by static relocation: Modify the second program on the fly as it loaded it into memory.

The lack of memory abstraction is still common in embedded and smart card systems.

A Memory Abstraction: Address Spaces

Address space is the set of addresses that a process can use to address memory.

Dynamic relocation uses base and limit registers to map each process’ address space onto a different part of physical memory in a simple way.

The disadvantage of relocation using base and limit registers is the need to perform an addition and comparison on every memory reference.

Swapping is used to deal with memory overload, bringing in each process in its entirety, running for a while, then putting it back on the disk.

When swapping creates multiple holes in memory, it’s possible to combine them all into one big one, which is called memory compaction. Free memory can be recorded as bitmaps or linked lists.

Modern Operating Systems 笔记 - Deadlocks

操作系统 算法 死锁

Resources

A preemptable resource is one that can be taken away from the process owning it with no ill effects.

A nonpreemptable resource is one that cannot be taken away from its current owner without causing the computation to fail.

Resource Acquisition

  1. Request the resource.
  2. Use the resource.
  3. Release the resource.

A possible implementation:

  1. down on the semaphore to aquire the resource.
  2. using the resource.
  3. up on the semaphore to release the resource.

上一页 下一页