Speed Reading "in-depth understanding of computer systems."

Speed ​​Reading this week, the "in-depth understanding of computer systems," the book, the book describes the inner workings of a computer system from a programmer's point of view, presents some concepts of the nature of how the correctness, performance and practical application of the practical impact nature. Harvest as follows:

1, on the processes and threads

  • Process is an abstraction of the operating system to run the program refers to a computer program has been running, the system is the basic unit of resource allocation and scheduling, is the underlying operating system architecture.
  • Threads are sometimes called lightweight processes, the operating system is the smallest unit capable of operation scheduling. A thread is a physical process, the thread does not own its own system resources, has only a little in the operation of essential resources, but it can be shared with other threads of the process belong to the same process have all the resources, mostly the same process It can be executed concurrently between threads.

2, several data transfer instruction

  • movl: transfer double words, a source operand specified value, may be immediate, may be stored in registers or in memory. Specify a destination operand location can be a register or memory address.
  • movw: transmitting two bytes, when one operand is a register, a register to be eight-byte elements in the following figure.
  • movb: transmitting a byte, when an operand registers, eight have a single byte register for the next element in FIG.
  • movsbl and movzbl responsible copy a byte, and set in the destination operand in the remaining bits.
    • Movsbl source operand is a single byte, and set high for the highest source 24 bytes, and then copied to the destination double word.
    • Movzbl source operand is a single byte preceded by 0 extension 24 to 32, then copied to the destination double word.

3, the register usage conventions

    IA32采用了一组统一的寄存器使用惯例,根据惯例,寄存器eax、edx、ecx被划分为调用者保存寄存器,当过程P调用Q时,Q可以覆盖这些寄存器,二不会破坏任何P所需要的数据;ebx、esi、edi被划分为被调用者保存寄存器,这意味着Q必须在覆盖这些寄存器之前,将这些寄存器中的值保存到栈中,并在返回前恢复它们,因为P可能会在今后的计算中需要这些值。由此根据惯例,必须保持寄存器ebp、esp。

4, Amdahl's Law

    Gene Amdahl做出了一个关于提高系统一部分性能的效果的简单但富有洞察力的观察,被称为Amdahl定律。其主要思想是当我们加快系统一个部分的速度时,对系统整体性能的影响依赖于这个部分有多重要和速度提高了多少。
    考虑一个系统在其中执行某个应用程序需要时间t,设系统某部分需要这个时间的百分比为a,二我们将它的性能提高到了k倍,因此整个执行时间为T=(1-a)t+(at)/k=t[(1-a)+a/k],由此可以得出加速S=1/[(1-a)+a/k]。例如原来占用60%时间的部分提高到了三倍即a=0.6,k=3,此时加速S=1.67。可以看出我们大幅度改进了系统的一个主要部分,但是净加速还是很小。
    所以Amdahl定律的主要观点就是要想大幅度提高整个系统的速度,必须提高整个系统很大一部分的速度。

5, cache lines, group and blocks What is the difference?

  • Block is a fixed-size packets, transmitted back and forth between the cache and the residency;
  • Row is stored in the cache block and other information in the container;
  • Group is a collection of one or more lines, direct mapped cache the group consisting of only one row, set-associative, and fully-associative cache roommate group of the plurality of rows.
    Group and direct-mapped cache lines are equivalent, but both associative cache can not be mixed.

6, the relocation procedure:

Relocation consists of two steps:

  • Relocation section and symbol definitions. The linker will want all the same type sections into the new section of the same type of polymerization, and then the linker memory address assigned to a new section of the polymerization runs, each node is assigned to the input module definition, and the definition assigned to the input module each symbol. Once this is accomplished, the program each instruction and global variables has a unique memory address of the runtime.
  • Reference symbol relocation section. Linker sections modify the code and data sections of each reference symbol, such that they point to the correct runtime addresses, performing this step will depend on the purpose of relocation table data structure relocatable object module.

7, based on the measurement function gettimeofday

Using this library function query system clock to determine the current date and time. This function of time is written to the structure of a caller passed over, this structure comprising a field unit is s, and a field unit of μs.

8, garbage collection

Garbage collection is a dynamic memory allocator, it automatically releases the program no longer needs the allocated blocks which are called garbage. Automatic recovery of heap memory process called garbage collection. A support for garbage collection in a system, the application explicitly assigned heap block, but not explicitly release them. In the context of a C program, an application calls malloc, but do not call free. Garbage collector periodically identify spam block corresponding call and free, the blocks back into the free list.

Guess you like

Origin www.cnblogs.com/fanxiaonan/p/11746217.html