Python: program is compiled and linked

1 Pretreatment

Pre-compilation process mainly deal with pre-compiled instructions to "#" in the beginning of the source files, the main processing rules are:

将所有的“#define”删除,并展开所用的宏定义
处理所有条件预编译指令,比如“#if”、“#ifdef”、 “#elif”、“#endif”
处理“#include”预编译指令,将被包含的文件插入到该编译指令的位置,注:此过程是递归进行的
删除所有注释
添加行号和文件名标识,以便于编译时编译器产生调试用的行号信息以及用于编译时产生编译错误或警告时可显示行号
保留所有的#pragma编译器指令。

2 compilation

After pre-compilation process is to document a series of lexical analysis, syntax analysis, generate the corresponding assembly code files semantic analysis and optimization. This process is the core of the program build.
3 compilation

The assembler is converted into assembly code to machine instructions can be executed, almost all of the compilation of statements each single machine instruction. After compiling, linking, assembly output file becomes the target file (Object File)
4 links

The main content of the link is to refer to each other between the various modules partially treated well, so that each module can correct splicing. The main link of the mass distribution process and address space (Address and Storage Allocation), symbol resolution (Symbol Resolution) and relocation (Relocation) and other steps.
5 static linking and dynamic linking

Statically linked method: statically linked when loading code will address the dynamic code of the program will be used to determine or dynamic code down link static library can use static linking, dynamic link libraries can also use this method to import link library

Dynamic linking method: Use this mode of procedure is not completed at the beginning of the dynamic link, but until the real calling the dynamic library code, the loader was calculated logical address (that part is called) dynamic code, and then wait until a a time, and the need to call another program when a dynamic code block, the logical address is calculated loader went this code, so this manner shorter initialization, but not as a static link performance during operation program
6 virtual memory technology

It means a virtual storage function and a permutation function request transferred, from the storage system to be logically expanded memory capacity.
7 tabs and segment

Paging: user program address space is divided into a plurality of areas of a fixed size, called a "page", and accordingly, the memory space is divided into several physical blocks, pages and blocks of equal size. Any one of a user program can be placed in any of a memory, to achieve the discrete distribution.

Segment: The user program address space is divided into several sizes of segments, each segment can define a logical group of relatively complete information. When the storage allocated to segments as a unit, section and paragraph in the memory can not be adjacent, but also to achieve a discrete distribution.
The main difference with the segment of the tab

页是信息的物理单位,分页是为了实现非连续分配,以便解决内存碎片问题,或者说分页是由于系统管理的需要.段是信息的逻辑单位,它含有一组意义相对完整的信息,分段的目的是为了更好地实现共享,满足用户的需要.
页的大小固定,由系统确定,将逻辑地址划分为页号和页内地址是由机器硬件实现的.而段的长度却不固定,决定于用户所编写的程序,通常由编译程序在对源程序进行编译时根据信息的性质来划分.
分页的作业地址空间是一维的.分段的地址空间是二维的.

8 page replacement algorithm

最佳置换算法OPT:不可能实现
先进先出FIFO
最近最久未使用算法LRU:最近一段时间里最久没有使用过的页面予以置换.
clock算法

9 edge-triggered and level-triggered

Edge refers to a trigger event occurs whenever io state changes, trigger condition is satisfied as long as it is a condition io event

Guess you like

Origin blog.csdn.net/weixin_44523387/article/details/91897383