首页 > 其他分享 >CS:APP--Chapter06 : the memory hierarchy(part 1)

CS:APP--Chapter06 : the memory hierarchy(part 1)

时间:2023-01-17 20:23:22浏览次数:68  
标签:-- bits APP Chapter06 memory DRAM disk data into

CS:APP--Chapter06 : memory hierarchy(part 1)

标签(空格分隔): CS:APP

目录


prologue

Back to the simple model of memory we often use before, the realistic implementation of it at low level isn't in correspondence with it. We get used to describing memory as a linear array accessed by an index followed by returning the data stored at the position of the index.

In practice, memory of computer system can be regraded as a pyramid-shaped hierarchy shown in section 3. All memory can be categoried into several classes, and these types of storage devices get larger, cheaper and slower as we move from top to bottom.

It also means that each kind of storage device has its own capacity and cost as well as speed. In this case, one probelem arises : how these storage devices works and organized and how to integrate
these into computer system. The details will be reported later.

As a result, memory provides a fundamental concept : locality, which is widely used in computer system and even network as a cache to directly response the request which has been accessed most recently without the intervining from servers.

One of the most significant advantages of having a better understanding of memory hierarchy is to optimize our code for the higher locality in terms of cache hit and miss.

1. storage technologies

The previous chapters introduces what processor is and how it works by transferring data between registers and main memory. Indeed, in the beginning statg of computer, it always held small volume of main memory and storage devices.

Up now, a loans of storage devices are shown such SRAM, DRAM and convential disk as well as SSD.

1.1 random access memory

There are two varieties originated from RAM : static and dynamic RAM, abbreviated to SRAM and DRAM.

SRAM is more expensive and faster than DRAM.

1.1.1 static RAM

six-transistor circuit constitutes a bistable memory cell (store bit here).

SRAM has three status :
此处输入图片的描述

the middle state in which the pendulum stays balanced in the vertical position is called by metastable.

One principle: as long as it is kept powered, the cell remains the position(just value inside) indefinitely. It otherwise will fall to either of stable postion.

Q : It recalls one point in OS, OS initializes computer by accessing a set of instructions stored in one fixed address block. Does the block lying out in SRAM? but it is bistable.

1.1.2 dynamic RAM

only one capacitor and a single access transistor -> memory cell

Unlike SRAM, DRAM is easily susceptible to disturbance and then cannot get recovery.

One reference where demonstrates what consists of DRAM at a hardware point of view. DRAM detail.

Due to DRAM only storing data over a short period, it must be periodically refreshed by reading bit out and rewriting another bit in.

So SRAM usually is used in high-speed cache memory but DRAM often is used in main memory and frame buffer.

conventional DRAM

All cells inDRAM are partitioned into \(d\) supercells consisting of \(w\) cells (\(w\) bits).

此处输入图片的描述

As shown above, the address is transferred via address bus to the **memory controller ** in main memory and it then is transferred to DRAM via pins adhering to DRAM.
On top of it, for reading bit out and rewriting bit in, data must also be transferred into DRAM via data bus and pin. ( There is a technology called as multiplexing by using less address pins than before, this is why DRAM are mapped into a two-dimensional array.)

Each supercell is accessed by row and column index with (i,j) produced by memory controller. And DRAM reads a word out directly to the memory controller.

type description
pros decrease the number of pins
cons increase the access time because of two distinct steps
memory modules

the DRAM chips are packaged into one memory modules that just plug into the empty and expansion slot on the matherboard.

To take the reference machine I7 for example:
240-pins inline memory modules(DIMM) to transfer data via a 64-bits chunks.

此处输入图片的描述

Something needs to be emphasized here : DRAM collects the eight supercell of 1 byte and then forms a word of 64-bits, which is returned to memory controller.

Upto now, we eventually make sense why writing is more time-comsuming than reading.

enhanced memory

So as to cut to the chase, more information is provided on page621.

accessing main memory

此处输入图片的描述

buses : a collection of parallel wires classifed into there categories : address,data,control buses.

I/O bridge : an interface(which includes memory controller) between system bused and memory buses.

the clock cycles required for MOVq %rax,A is more than MOVq A,%rax.

1.1.3 disk storage

It takes a hundred thousand times longer to read and write information from disk than from SRAM and DRAM.

disk geometry

此处输入图片的描述

The spindle in the center of the platter just spins the platter at a fixed rate.

The rings on the platter surface are named track, and it is partitioned into several set of sectors, which stores data bits, and are separated by gaps where no data bits are stored but formatting bits that identifies sectors instead.

Because there are multiple cyclinders on (b) and the consistency between cyclinder and track, we are used to using cyclinder instead of track in multiple-platter view.

disk capacity

disk capacity is the maximum nubmber of bits can be recorded by a disk.

To put it another way:

capacity = N(bits per sector) * N(sector per track) * N(track per surface)N(surface per platter)N(platter per disk)

disk operation

To slide read/write head over surface by moving actuator arm can accomplish read and write operation on platter. And this design makes every track accessable for the head.

In this case, If CPU issues the read operation on some block of disk,

  1. head must be above the correct track.
  2. the sector must be under the head
  3. data can be transferred later

In this case, the access time to a block of disk has three main components :

  1. seek time
  2. rotational latency
  3. transfer time

Each of time is the time required to finish the work identified by the same number above.

logical disk blocks

It hides the complexity of disk geometry that mapping A identifier to a triple (surface,track,sector) by the firmware in the disk controller, which performs as same functionality as memory controller.

connecting I/O devices

此处输入图片的描述

Considering the imcompatiblity between I/O buses buses and external buses, some controllers play an important role in formatting input.

access disk

We can start with three technologies : memory-mapping I/O and direct memory access as well as interruption that we will discuss later.

memory-mapping I/O:
From an abstract point of view, we can regard each of I/O devices as an address. It's much easy to manipulate these device by writing and reading the data in the block starting with this address.

DMA :
Disk controller can directly move data in disk to a block of memory without the intervening from processor.

SSD

标签:--,bits,APP,Chapter06,memory,DRAM,disk,data,into
From: https://www.cnblogs.com/UQ-44636346/p/17058637.html

相关文章

  • 文件上传和邮件发送
    文件上传和邮件发送1、文件上传在Web应用中,文件上传和下载功能是非常常用的功能,今天来实现一下JavaWeb中的文件上传和下载功能1.1、准备工作对于文件上传,浏览器在上传......
  • drf-Response drf-request.data 序列化类的使用 反序列化新增、修改、删除数据
    目录APIView基本使用使用原生Django写接口(View+JsonResponse)使用drf写接口(APIView+drfResponse)drf两种导入View的方式drfResponseAPIView源码分析Request类源码......
  • 计算机如何查看硬盘型号
     001、win+e快捷键打开资源管理器  002、右击c盘,然后点击属性   003、点击硬件,即可看到硬盘的具体型号 ......
  • 依赖项构造方法注入示例
    我们可以通过构造函数注入依赖项。 <bean>的 <constructor-arg>子元素用于构造函数注入。在这里,我们要注入原始和基于字符串的值从属对象(包含对象)集合值等注入原始值......
  • 学习笔记——Spring中的注解;Spring中装配对象的注解;使用注解配置对象中属性
    2023-01-17一、Spring中的注解 1、使用注解的原因(1)使用注解将对象装配到IOC容器中(2)使用注解管理对象之间依赖关系(自动装配)2、Spring中装配对象的注解(1)@Component标......
  • 涂满它!(涂色问题 (原题:水叮当的舞步))题解
    F.涂满它!内存限制:256MiB时间限制:1000ms标准输入输出题目类型:传统评测方式:文本比较题目描述Flood-it是谷歌+平台上的非常好玩的一款游戏,游戏界面如下所示:在......
  • dremio distribution 模块简单说明
    以下简单说明下dremiodistribution,distribution核心是进行项目的发布,这种模式经常在apache类似项目中看到参考项目结构  简单说明jdbc-driver还是是对于jdbc......
  • 学习记录-桥接模式
    桥接模式桥接(Bridge)是用于把抽象化与实现化解耦,使得二者可以独立变化。将继承关系转换为关联关系。这种类型的设计模式属于结构型模式,它通过提供抽象化和实现化之间的桥接......
  • 2023牛客寒假算法基础集训营1题解
    写在前面全文收集了部分学长以及我自己的代码,本蒟蒻第一次写博客,效果不好请见谅TwT原题链接:https://ac.nowcoder.com/acm/contest/46800#questionA:WorldFinal?WorldC......
  • 喵喵题
    感觉挺妙的题目啊喵~一个正整数\(N(N\le9\times10^{18})\),保证\(N=p^2q\)且\(p,q\)为质数,求\(p,q\)。考虑暴力,最朴素的暴力就是枚举\(p\)或\(q\),判......