2008-02-22

读<<深入理解计算机系统>>第一章

=

1. 一些中英文名词对照
a. preprocessor, compiler, assembler, and linker
On a Unix system, the translation from source file to object file is performed by a compiler driver:
unix> gcc -o hello hello.c

Here, the GCC compiler driver reads the source file hello.c and translates it into an executable object file hello. The translation is performed in the sequence of four phases shown in Figure 1.3. The programs that perform the four phases ( preprocessor, compiler, assembler, and linker) are known collectively as the compilation system.

. Preprocessing phase(预处理阶段). The preprocessor (cpp)modifies the original C program according to directives that begin with the # character. For example, the #include <stdio.h> command in line 1 of hello.c tells the preprocessor to read the contents of the system header file stdio.h and insert it directly into the program text. The result is another C program, typically with the .i suffix.

. Compilation phase(编译阶段). The compiler (cc1) translates the text file hello.i into the text file hello.s, which contains an assembly-language program. Each statement in an assembly-language program exactly describes one low-level machine-language instruction in a standard text form. Assembly language is useful because it provides a common output language for different compilers for different high-level languages. For example, C compilers and Fortran compilers both generate output files in the same assembly language.

. Assembly phase(汇编阶段). Next, the assembler (as) translates hello.s into machine-language instructions,packages them in a form known as a relocatable object program, and stores the result in the object file hello.o. The hello.o file is a binary file whose bytes encode machine language instructions rather than characters. If we were to view hello.owith a text editor, it would appear to be gibberish.

. Linking phase(链接阶段). Notice that our hello program calls the printf function, which is part of the standard C library provided by every C compiler. The printf function resides in a separate precompiled object file called printf.o, which must somehow be merged with our hello.o program. The linker (ld) handles this merging. The result is the hello file, which is an executable object file (or simply executable) that is ready to be loaded into memory and executed by the system.

b. CPU Load, Store, Update, I/O Read, I/O Write and Jump
. Load(加载):从主存拷贝一个字节或者一个字到寄存器,覆盖寄存器原来的内容
. Store(存储):从寄存器拷贝一个字节或者一个字到主存的某个位置,覆盖这个位置上原来的内容
. Update(更新):拷贝两个寄存器的内容到ALU,ALU将两个字相加,并将结果存放到一个寄存器中,覆盖该寄存器中原来的内容
. I/O Read(I/O读):从一个I/O设备中拷贝一个字节或者一个字到一个寄存器
. I/O Write(I/O写):从一个寄存器中拷贝一个字节或者一个字到一个I/O设备
. Jump(跳转): 从指令本身中抽取一个字,并将这个字拷贝到程序计数器(PC)中,覆盖PC中原来的值

2. 操作系统提供的抽象表示
files are abstractions for I/O devices. Virtual memory is an abstraction for both the main memory and disk I/O devices. And processes are abstractions for the processor, main memory, and I/O devices.


文件是对I/O设备的抽象,虚拟存储器是对主存和磁盘I/O设备的抽象,进程是对处理器,主存和I/O设备的抽象

No comments: