20145326 Cai "Information Security system Design" 7th Week study Summary

Source: Internet
Author: User

Summary of learning contents of textbook

In a simple model, the memory system is a linear byte array, and the CPU can access each memory location within a constant time. In fact, a memory system is a hierarchical structure of storage devices with different capacity, cost, and access times. Some of the contents of the book I will not repeat, just need to summarize some of the important points of knowledge.

Storage technology
  • Static RAM (SRAM): Used as cache memory, each bit stored in a bistable memory unit. Bistable means that the circuit can be maintained indefinitely in two different voltage configurations or one of the states. As long as the power supply, it will remain unchanged. Even if there is interference, such as electrical noise, to disrupt the voltage, the circuit reverts to a stable value when the interference is eliminated. Its不需要刷新, 存取速度快 , 对光电噪声不敏感 ,晶体管多密集度低 ,功耗贵代价高 。

  • Dynamic RAM (DRAM): A frame buffer used as the primary storage and graphics system. Each bit is stored as a charge to a capacitor, and when the voltage of the capacitor is disturbed, he will never recover again. Exposure to light can cause a change in the capacitance voltage. Its以纳秒为周期刷新,存取速度慢,光电因素易导致电压改变,电容小,密集度高, 功耗低。

  • One of the reasons that circuit designers organize DRAM into two-dimensional arrays instead of linear arrays 降低芯片上地址引脚的数量 . Of course, the disadvantage of the two-dimensional array organization is that it has to send the address in two steps, which increases the access time.

  • Programmable ROM (PROM): can only be programmed once. Prom Each storage unit has a fuse that can only be fused once with a high current.

  • Erasable programmable ROM (EPROM): ultraviolet light shines through the window, the EPROM is cleared to 0, the number of erased and reprogrammed is 1000 times.

  • Electronic erasable ROM (EEPROM): There is no need for a physically separate programming device, so it can be programmed directly on the printed circuit card and can be programmed in the number of 10^5.

  • Flash: Based on EEPROM, provides fast and durable nonvolatile storage for a large number of electronic devices.

  • Disk structure (disk drive) structure:,,,, 盘片 磁道 扇区 间隙柱面。

  • Disk capacity

  • Access time: 寻道时间 , 旋转时间 , 传送时间 .

  • Logical Disk BLOCK: Memory can be considered as a byte array, disk can be seen as a block array, each logical block number can be translated into one ( 盘面 , 磁道 , 扇区 ) triples.

  • Depending on the carrying signal, the bus can be divided into 数据总线 地址总线 控制总线 three kinds.

  • The CPU uses memory-mapped I/O technology to issue commands to I/O devices.

Locality of
    • There are two forms of locality: 时间局部性 , 空间局部性 .

    • 程序访问一个向量,步长越大空间局部性越差

    • A program that repeatedly references the same variable has good time locality, and for a program with a reference pattern with a step size of K, the smaller the step size, the better the spatial locality, and the good time and space locality of the loop for taking the instruction. The smaller the loop body, the greater the number of iterations, the better the locality.

Memory hierarchy
    • The central idea of the storage hierarchy is 上层作为下层的缓存 .

    • Time locality: Once a data has been copied to the cache for the first time, we expect a series of access hits to that target later.

    • Using spatial locality: Blocks typically contain multiple data objects, and we usually expect that subsequent access to other objects in that block will compensate for the cost of copying the block after a miss.

    • When the cache is not hit, decide which block is to be controlled by the sacrifice block, 替换策略 the miss of the empty cache is called 强制性不命中 or 冷不命中 the reason for the capacity miss is 缓存太小 .

Cache memory
    • The cache structure can be described in tuples (S,E,B,m) . The size of the cacheC = S * E * B。

    • Each storage address of a computer system has m-bits, which form m=2^m different addresses.

    • The cache is organized into an S=2^s array of cache groups, each containing an e cache line, each consisting of a B=2^b byte block, a valid bit t=m-(b+s) , and a token bit that uniquely identifies the block stored in the cache row.

Learning processcode-driven programming learning

Git has been installed before, first install the tree

Then enter mkdir 20145326csapp2e to create your own code folder "20145326csapp2e",

Enter the CD 20145326csapp2e to enter the folder and set up the appropriate sub-folders. Then enter CD src into the folder and create 12 chapters corresponding to the folder.



View with tree:

Create a new "Hello World" program in the "01intro" folder and run it.

The end is git code. Before that, create a new project "CSAPP2E" in the code cloud.

Results of Git success:

Then follow this process and continue pushing the rest of the code for the week.

Lab building Work (it's fun!) )

Install Fortune:

Exercises

Exercise 6.2

Calculate the capacity of such a disk. It has 2 platters, 10 000 cylinders, each track has an average of 400 sectors, and each sector has an average of 512 bytes.

Disk capacity = (512/400)1000022 = 8 192 000 000 byte = 8.192GB

Exercise 6.3

Estimate the time (in MS) that is required to access a sector on one of the following disks. Rotation rate: 15000rpm;taveseek = 8ms; Average number of sectors per track: 500

Access time = Taveseek+taverotation+tavetransfer = 8ms +0.51/15000rpm60secs.min1000ms/s+1/15000rpm1/50060secs/ Min1000ms/s=8ms+2ms+0.008ms=10.008ms

Exercise 6.4

Assume that 1MB files consist of 512-byte logical blocks stored on a disk drive with the following characteristics (rotation rate: 000rpm,taveseek=5ms, average sector/track = 1000).
(1) Best case: the best possible mapping of a given logical block to disk sector (i.e., sequential), estimating the optimal time required to read this file
(2) Random case: If the block is randomly mapped to the disk sector, the estimated time required to read this file

(1)T=Taveseek+Taverotation+2Tmaxrotation=5ms+3ms+26ms=20ms

(2) In this case, the block is randomly mapped to the sector, and each block of Read 2000 is required Taveseek+Tavgrotation=8ms . So the total time to read this file isT = 8ms*2000=16000ms=16s

Exercise 6.8

Changes the order of the loops in the original function so that it scans the three-bit array A in a reference pattern of step 1.

int sumarray3d(int a[N] [N] [N]){int i,j,k,sum=0;for(k=0;k<N;k++){for(i=0;i<N;i++){for(j=0;j<N;j++){sum += a[k] [i] [j];}}}return sum;}

Exercise 6.9

Determine the spatial locality of the three functions in a graph.

The function clear1 accesses the array in a reference pattern of step 1, so it has the best spatial locality, and the function CLEAR2 scans each of the n structures sequentially, which is also possible, but in each structure it jumps to the following offset from the structure's starting position in a pattern that is not 1 in stride. Therefore, the spatial locality of CLEAR2 is worse than that of clear1, and the function clear3 not only jumps in each structure, but also jumps from structure to structure, so CLEAR3 has the worst spatial locality.

Exercise 6.11

In the previous Dotprod example, what is the hit rate for all references to X and Y after we have populated the array x?

In the case of the Dotprod example, when the array x is defined as float x[12] , the padding eliminates the conflict misses, that is, the block that does not occur is y[0] ~ y[3] copied to group 0, overwriting the previous reference to the value of the x that was copied, so 四分之三 the reference is hit.

Exercise 6.13

There are two lows that are 块偏移(CO) , then three bits 组索引(CI) , the rest of the bits as 标记(CT) .

Code Hosting Scenarios

Code Managed connections

Add a detailed comment to all the code:

Number of code statistics lines:

Learning progress Bar
Lines of code (new/cumulative) Blog volume (Add/accumulate) Learning time (new/cumulative) Important growth
Goal 5000 rows 30 Articles 400 hours
First week 0/0 1/2 20/20
Second week 58/58 1/3 20/40
Third week 150/208 1/4 22/62
Week Five 150/358 1/5 21/83
Week Six 136/494 1/6 25/108
Seventh Week 115/609 1/7 24/132

Experience

This week's learning content is mainly to understand the type and characteristics of storage devices, as well as the local principle and caching ideas in the storage hierarchy of applications, most of the knowledge in the previous chapters of the study are more or less involved, such as the core idea of storage is each layer of storage devices as the next layer of "cache" and so on, with the previous foundation The study of this chapter is not particularly strenuous. Calm down, next to a page of reading materials, while watching the understanding, harvest or relatively large. After learning this part of the knowledge, I know more about the classification of memory, more in-depth understanding of the process of data transmission. To say the difficult words, or direct mapping of the cache running process of that part of the knowledge, the initial feeling is more vague, but after learning to group-linked cache and the full-phase cache, the three processes together to see can understand the tag, group index, block offset the respective role. I have always thought that it is absolutely impossible to take a short cut at all without reading the textbook, and we must devote a lot of time and energy to the harvest. The most important thing is to put a positive attitude, do not deal with, do not perfunctory. We should explore the fun of learning and enjoy the process of learning, which is perfect. I will set a small goal for myself every week ~ Keep on moving forward!!! Strive to get the prize from Lou Teacher early! Haha, huh! ~

20145326 Cai "Information Security system Design" 7th Week study Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.