存储器概述
Storage
和 Memory
翻译成中文都有存储器的意思,但是前者通常指的是长期存储数据的组件,比如硬盘;后者通常指的是短期存储数据的组件,比如内存。
在冯诺依曼结构中,五大经典部件中的存储器应该是狭义上的存储器,实际指的是 Memory
,是 CPU 可以直接寻址访问的存储空间。而 CPU 不能直接访问硬盘,需要通过 I/O
指令将数据复制到内存,因此硬盘属于 I/O
设备,被 CPU 当做外设。
而在整个存储系统中,指的是广义概念上的存储器,所有用来存储数据和指令的部件都叫存储器,包括内存、硬盘、U 盘等。
存储器技术
只读存储器 ROM (Read Only Memory
)
数据事先写入后只能读取而不能改写,如计算机启动用的 BIOS
就是固化到计算机主板的 ROM
芯片上的程序
为便于使用和大批量生产,进一步发展出了可编程只读存储器(PROM
)、可擦可编程序只读存储器(EPROM
)和电可擦可编程只读存储器(EEPROM
)等
随机存取存储器 RAM (Random Access Memory
)
动态随机存取存储器 DRAM (
Dynamic RAM
)静态随机存取存储器 SRAM (
Static RAM
)
快闪存储器简称闪存
闪存是一种特殊的、以宏块抹写的 EEPROM
,虽然由 ROM
发展而来,但是可以读写。
U盘(USB 闪存盘)、CF卡、SM卡、SD/MMC卡、记忆棒、XD卡、MS卡、TF卡、PCIe闪存卡等都是闪存卡,外观不同,但技术原理相同。
手机的机身内存 ROM
,虽然仍被叫做 ROM
,但采用的是闪存技术 EEPROM
,是可以读写的,主要用来存储手机操作系统,但由于操作系统一般不会占满机身内存,留下的一部分开启了写入权限,可以像硬盘一样存储数据。
机身内存
ROM
可以简单的对应理解为计算机硬盘,手机运存RAM
可以简单的对应理解为计算机内存条。
手机内存卡也是采用的闪存技术,用来扩展机身内存,可以归入离线存储器中。
磁盘
软磁盘即软盘
硬磁盘即硬盘
存储器层次
存储器的速度影响性能,存储器的容量限制运算的规模,因此人们希望存储器速度更快,容量更大,而价格更便宜,设计师们最终通过存储器层次来解决这些相互矛盾的需求。
在存储器层次中,速度最快、容量最小并且每位价格最贵的存储器处于顶层,而速度最慢、容量最大并且每位价格最便宜的存储器处于最底层。
主存储器
主存储器也叫主存、内存储器、内存,英文名有 Primary Storage
、Primary Memory
、Main Memory
、Internal Memory
。
它是 CPU
能直接访问的存储器,它的特点是存取速率快,但容量小,每位价格贵。
BIOS 芯片
它是一个 ROM 存储器,它保存着计算机最重要的基本输入输出的程序(Basic Input Output System 缩写为 BIOS)、开机后自检程序和系统自启动程序
寄存器(Registers)
也称为控制存储器,用于临时存储参与运算数据。通常集成于 CPU 中,其速度是所有存储器中速度最快的。
高速缓冲存储器(Cache Memory)
简称高速缓存或直接称缓存,采用
SRAM
技术对数据进行缓冲,使得频繁使用的数据 CPU 不必每次都从内存中获取。通常集成于 CPU 中,其容量较小但是存取数据速度仅次于寄存器。大容量内存储器
采用
DRAM
技术,用来存储运行的程序和数据,其存取数据的速度较快,存储数据的容量较大。内存的衡量标准主要有存储容量、存取时间、存储周期和存储器带宽四个指标。其中存储容量是一个存储器中可以容纳的存储单元总数,通常以字数或字节数作为单位;存取时间则是启动到完成一次存储器操作所经历的时间,通常以纳秒(ns)为单位;存储周期则是连续启动连词操作所需间隔的最小时间,通常以纳秒(ns)为单位;存储器带宽表示单位时间内存储器所存储的信息量大小,通常以位/秒或字节/秒为单位。后三者是其存取速度的主要衡量标准。
关于主存、内存的关系及涵盖的计算机部件范围,网上的说法非常混乱。从内存储器的概念出发,我个人更偏向于把以上几种都归为内存储器的范围,并且主存储器=内存储器,而我们平时说的内存,是特指的大容量内存储器,是一种既成事实的不严谨说法。
其实名词只是一种用来帮助理解事物本身的说法,关键在于理解事物本身。本部分使用的名词主要参考的是维基百科上的表述:Computer data storage 和 Talk:Computer_data_storage
二级存储器
二级存储器又叫辅助存储器、辅存、外部存储器、外存,英文名有 Secondary Storage
、Auxiliary Storage
、External Memory
它是 CPU
不能直接访问的存储器,它的特点是存取速率慢,但容量大,每位价格便宜。
指大容量存储设备,比如磁盘,磁盘包括硬磁盘(硬盘)和软磁盘(软盘),软盘已经被淘汰(不过一些仍在服役的老旧设备可能还在使用软盘)
三级存储器
三级存储器主要是指超大型数据存储,主要用来存放很少访问的信息,通常在使用前需要将信息复制到二级存储器。
三级存储器不需要人工干预,当计算机需要从三级存储器中读取信息时,它将首先查询目录数据库以确定哪个磁带或光盘包含该信息。接下来,计算机将指示机械臂获取介质并将其放入驱动器中。当计算机读取完信息后,机械臂会将介质返回到库中的位置。
离线存储器
离线存储器主要用于传输信息和存档。
离线存储器必须要人工插入或连接。
大多数辅助存储和三级存储的存储介质也可以用于离线存储。
信息单位
比特(
bit
)亦称位、二进制位、比特位、位元,指二进制数中的一位,是计算机中信息表示的最小单位。
习惯上以小写字母
b
表示字节(
Byte
)又称位元组,是信息的一种基本计量单位,是由连续的、固定数量的位(即比特)所组成的位串(即比特串),一般由 8 个二进制位组成,即
1 Byte = 8 bit
以前也有过4位、6位、7位、12位或18位作为一个字节的标准,只是现代计算机的事实标准就是用 8 位来代表一个字节
正是因为这个原因,在很多较为严谨的技术规格文献中,为了避免产生歧义,更倾向于使用 8 位组(Octet)而不是字节(Byte)这个术语来强调 8 比特串。字节是存储器的最小存取单位,一般也是处理器的最小寻址单位。
也有按位寻址、按字寻址的处理器,但在个人计算机上应用不普遍
字
虽然字节是大多数现代计算机的最小存储单位和传输单位,但并不代表它是计算机可以最高效地处理的数据单位。
在计算机中,一串比特位(即位串、比特串)是作为一个整体来处理或运算的,这串比特位称为一个计算机字,简称字,是计算机中的基本访问单位。
字长即字的长度,是指计算机的每个字所包含的位数。字长决定了CPU一次操作所处理的实际比特位数量的多少。字长由 CPU 对外数据通路的数据总线宽度决定。
在目前来讲,桌面平台的处理器字长正处于从32位向64位过渡的时期,嵌入式设备基本稳定在32位,而在某些专业领域(如高端显卡),处理器字长早已经达到了64位乃至更多的128位
千字节
KB
和KiB
原始定义为
2^{10} = 1024
,但有些存储系统将其重新定义为10^{3} = 1000
,为了避免混淆,用KB
表示10^{3} = 1000
,用KiB
表示2^{10} = 1024
缩写 | 数值 | 缩写 | 数值 |
---|---|---|---|
KB | 10^{3} |
KiB | 2^{10} |
MB | 10^{6} |
MiB | 2^{20} |
GB | 10^{9} |
GiB | 2^{30} |
TB | 10^{12} |
TiB | 2^{40} |
PB | 10^{15} |
PiB | 2^{50} |
EB | 10^{18} |
EiB | 2^{60} |
ZB | 10^{21} |
ZiB | 2^{70} |
YB | 10^{24} |
YiB | 2^{80} |