码迷,mamicode.com
首页 > 其他好文 > 详细

CHAPTER 1 ----- a tour of computer sysytems(2)

时间:2018-04-14 18:09:17      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:ted   pass   代码   inf   xpl   string   cts   存储器   desc   

 

1.3 It pays to understand how compilation systems work

Why programmers need to understand how compilation systems work?

1)Optimizing program performance.We do need a basic understanding of machine-level code and how the compiler translation different C statements into machine code.

chapter 3 ———how compilers translate different C constructs into these languages.

chapter 5———making simple transformations to the C code that help the compiler do its job better.

chapter 6———learn the hierarchical nature of the memory system,how C compilers store data arrays in memory and how your C programs can exploit this knowledge to run more efficiently.

2)Understanding link-time errors(链接时出现的错误).———chapter 7

3)Avoiding secuirty holes.Buffer overflow vulnerabilities (缓冲区溢出错误)have accounted for the majority of security holes in network and Internet servers. Too few programmers undertand the need to carefully restict the quatity and forms of data they accept from untrusted sources.A first step in learning secure programming is to understand the consequences of the way data and control information are stored on the program stack.

chapter 3———We cover the stack discipline and buffer overflow vulnerabilities as part of our study of assembly language.

1.4 Processors read and interpret instructions stored in memory

The shell(an application program) is a command-line interpreter that prints a prompt(提示符,即"linux>"),waits for you to tpye a command line,and then performs the commond.The shell loads and runs the hello program and then waits for it to terminates(because hello is not a built-in shell command).The shell then prints a prompt and wait for the next input command line.

 技术分享图片

 

1.4.1Hardware organization of a system

技术分享图片

CPU:Central processing Unit;ALU:Arithmetic/Logic unit;PC:Program counter;USB:Universal Serial Bus.

 

Buses:Running throughtout the system is a collection of electrical conduits(电缆/电子通道) called buses that carry bytes of information back and forth between the components.Buses are typically designed to transfer fixed-sized chunks of bytes known as words.

贯穿整个系统的是一组电子管道,称为总线,他携带信息字节并负责在各个部件间传递。

I/O devices:Input/output(I/O)devices are the system‘s connection to the external world.Each I/O devices is connected to the I/Obus by either controller or an adapter.The distinction between the two(controller and adapter) is mainly one of packaging(封装方式).Controller are chip sets in the device itself or on the system‘s main printed circuit board (often called motherboard主板).An adapter is a card that plugs into a slot on the motherboard. Regardless,the purpose of each is to transfer information back and forth between the I/O bus and I/O device.

 

Main memory:it is a temporary storage device that holds both a program and the data (that) it manipulates while the processor is executing the program.Physically,main memory consist of a collection of(一组) dynamic random access memory(DRAM)chips.Logically,memory is organized as a linear array of bytes(一个线性字节数组),each with its own unique address (array index 数组索引)starting at zero(这些地址是从零开始的).

 

Processor:the central processing unit(CPU)is the engine that interprets(or executes)instructions stored in main memory.At its core is a word-sized storage device(or register)called the program counter(PC).At any point in time,the PC points at (contains the address of )some machine-language instrcution in main memory.

处理器是解释(执行)存储在主存中指令的引擎,处理器的核心是一个大小为1个字的存储设备(寄存器),称为程序计数器(PC)。在任何时刻,PC都指向主存中的一条机器语言的指令(即含有该指令的地址)。

A processor reads the instruction from memory pointed at by the program counter(PC),interprets the bits in the instruction,performs some simple operation dictated by the instruction(执行该指令指示的简单操作),and then updates the PC to point to the next instruction,according ot its instruction set architecture.

the simple operation :Load:copy a byte or a word from main memory into a register,overwriting(覆盖) the previous contents of the register;store:copy a byte or a word from a register to a location in main memory(主存的某个位置),overwriting the previous contents of that location;operate:copy the contents of two register to the ALU,perform an arithmetic operation on the two words,and store the result in a register,overwriting the previous contents of that register,jump:extract a word from the instrunction itself (从指令本身提取一个字)and copy that word into the PC,overwriting  the previous value of the PC.

We can distinguish the processor‘s instruction set architecture,describing the effect of each machine-code instruction,from its microarchitecture,describing how the processor is actually implemented.

我们将处理器的指令集架构和处理器的微体系结构区分,前者描述的是每条机器代码指令的效果,后者描述的是处理器实际的实现方式。

 

1.4.2Running the hello program

 command from the keyboard:

技术分享图片

load hello(Using a technique known as direct memory access,DMA,the data travels directly from disk to main memory,without passing throught the processor ):

技术分享图片

execute:string from memory to the register file ,and from there to the display device.

技术分享图片

 1.5Caches Matter

To deal with the processor-memory gap,system designers include smaller faster storage devices called cache memories that serve as temporary staging areas for informaiton that the processor is likely to need in the near future.An L1cache on the processor chip holds tens of thousands of bytes and can be accessed nearly as fast as the register file.A larger L2 cache with hundreds of thousands to millions of bytes is connected to the processor by a special bus.It may take 5 times longer for the process to access the L2 cache than the L1 cache,but this is still 5 to10 times faster than accessing the main memory.

L1 and L2 caches are implemented with a hardware technology known as static random access memory(SRAM).some have three levels of caches:L1,L2 and L3.

The idea behind caching is that a system can get the effect of both a very large memory and a very fast one by exploiting locality,the tendency for programs to access data and code in localized regions.

技术分享图片

 

 

1.6 Storage devices form a hierarchy

The main idea of a memory hierarchy is that storage at one level serves as a cache for storage at the next lower level.上一层的存储器作为低一层存储器的高速缓存。

技术分享图片

 

CHAPTER 1 ----- a tour of computer sysytems(2)

标签:ted   pass   代码   inf   xpl   string   cts   存储器   desc   

原文地址:https://www.cnblogs.com/SsoZhNO-1/p/8832192.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!