【计算机科学速成课】- 第十九章内存&储存介质-Memory & Storage

时间:2021-9-14     作者:smarteng     分类: 课程视频


第十九章内存&储存介质-Memory & Storage

翻译内容

Hi, I'm Carrie Anne, and welcome to Crash Course Computer Science!
(。・∀・)ノ゙嗨,我是 Carrie Anne,欢迎收看计算机科学速成课!

We've talked about computer memory several times in this series,
系列中 我们多次谈到内存(Memory)

and we even designed some in Episode 6.
甚至在第 6 集设计了一个简单内存

In general, computer memory is non-permanent.
一般来说,电脑内存是 "非永久性"

If your xbox accidently gets unplugged and turns off,
如果 Xbox 电源线不小心拔掉了,内存里所有数据都会丢失

any data saved in memory is lost.
如果 Xbox 电源线不小心拔掉了,内存里所有数据都会丢失

For this reason, it's called volatile memory.
所以内存叫"易失性"存储器

What we haven't talked so much about this series is storage,
我们还没谈过的话题 是存储器(Storage)

which is a tad different.
存储器(Storage)和内存(Memory)有点不同

Any data written to storage, like your hard drive,
任何写入"存储器"的数据,比如你的硬盘 \N 数据会一直存着,直到被覆盖或删除,断电也不会丢失

will stay there until it's over-written or deleted, even if the power goes out.
任何写入"存储器"的数据,比如你的硬盘 \N 数据会一直存着,直到被覆盖或删除,断电也不会丢失

It's non-volatile.
存储器是"非易失性"的

It used to be that volatile memory was fast and non-volatile storage was slow,
以前是"易失性"的速度快,"非易失性"的速度慢

but as computing technologies have improved, this distinction is becoming less true,
但随着技术发展,两者的差异越来越小

and the terms have started to blend together.
但随着技术发展,两者的差异越来越小

Nowadays, we take for granted technologies like this little USB stick,
如今我们认为稀松平常的技术,比如这个 U 盘

which offers gigabytes of memory, reliable over long periods of time, all at low cost,
能低成本+可靠+长时间 存储上 GB 的数据

but this wasn't always true.
但以前可不是这样的

The earliest computer storage was paper punch cards,
最早的存储介质是 打孔纸卡 \N 以及纸卡的亲戚 打孔纸带

and its close cousin, punched paper tape.
最早的存储介质是 打孔纸卡 \N 以及纸卡的亲戚 打孔纸带

By the 1940s, punch cards had largely standardized into a grid of 80 columns and 12 rows,
到1940年代,纸卡标准是 80列x12行

allowing for a maximum of 960 bits of data to be stored on a single card.
一张卡能存 960 位数据 (80x12=960)

The largest program ever punched onto cards, that we know of,
据我们所知的 最大纸卡程序

was the US Military's Semi-Automatic Ground Environment, or SAGE,
是美国军方的"半自动地面防空系统" 简称 SAGE

an Air Defense System that became operational in 1958.
一个在 1958 年投入使用的防空系统

The main program was stored on 62,500 punchcards,
主程序存储在 62,500 个纸卡上

roughly equivalent to 5 megabytes of data,
大小 5MB 左右, 相当如今手机拍张照

that's the size of an average smartphone photo today.
大小 5MB 左右, 相当如今手机拍张照

Punch cards were a useful and popular form of storage for decades,
纸卡用了十几年,因为不用电而且便宜耐用

they didn't need power, plus paper was cheap and reasonably durable.
纸卡用了十几年,因为不用电而且便宜耐用

However, punchcards were slow and write-once,
然而坏处是读取慢,只能写入一次

you can't easily un-punch a hole.
打的孔无法轻易补上

So they were a less useful form of memory,
对于存临时值,纸卡不好用

where a value might only be needed for a fraction of a second during a program's execution,
对于存临时值,纸卡不好用

and then discarded.
对于存临时值,纸卡不好用

A faster, larger and more flexible form of computer memory was needed.
我们需要更快更大更灵活的存储方式

An early and practical approach was developed by J. Presper Eckert,
J. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法

as he was finishing work on ENIAC in 1944.
J. Presper Eckert 在 1944 年建造 ENIAC 时发明了一种方法

His invention was called Delay Line Memory, and it worked like this.
叫"延迟线存储器"(Delay Line Memory)原理如下

You take a tube and fill it with a liquid, like mercury.
拿一个管子装满液体,如水银

Then, you put a speaker at one end and microphone at the other.
管子一端放扬声器,另一端放麦克风

When you pulse the speaker, it creates a pressure wave.
扬声器发出脉冲时 会产生压力波

This takes time to propagate to the other end of the tube,
压力波需要时间 传播到另一端的麦克风

where it hits the microphone,
压力波需要时间 传播到另一端的麦克风

converting it back into an electrical signal.
麦克风将压力波 转换回电信号.

And we can use this propagation delay to store data!
我们可以用压力波的传播延迟 来存储数据!

Imagine that the presence of a pressure wave is a 1
假设有压力波代表 1,没有代表 0

and the absence of a pressure wave is a 0.
假设有压力波代表 1,没有代表 0

Our speaker can output a binary sequence like 1010 0111.
扬声器可以输出 1​​010 0111

The corresponding waves will travel down the tube, in order,
压力波沿管子传播,过了一会儿,撞上麦克风,

and a little while later, hit the microphone,
压力波沿管子传播,过了一会儿,撞上麦克风,

which converts the signal back into 1's and 0's.
将信号转换回 1 和 0

If we create a circuit that connects the microphone to the speaker,
如果加一个电路,连接麦克风和扬声器

plus a little amplifier to compensate for any loss,
再加一个放大器(Amplifier)来弥补信号衰弱

we can create a loop that stores data.
就能做一个存储数据的循环

The signal traveling along the wire is near instantaneous,
信号沿电线传播几乎是瞬时的,

so there's only ever one bit of data showing at any moment in time.
所以任何时间点只显示 1 bit 数据

But in the tube, you can store many bits!
但管子中可以存储多个位(bit)

After working on ENIAC, Eckert and his colleague John Mauchly,
忙完 ENIAC 后,Eckert 和同事 John Mauchly

set out to build a bigger and better computer called EDVAC, incorporating Delay Line Memory.
着手做一个更大更好的计算机叫 EDVAC,使用了延迟线存储器

In total, the computer had 128 Delay Lines,
总共有 128 条延迟线,每条能存 352 位(bits)

each capable of storing 352 bits.
总共有 128 条延迟线,每条能存 352 位(bits)

That's a grand total of 45 thousands bits of memory,
总共能存 45,000 位(bit)

not too shabby for 1949!
对 1949 年来说还不错!

This allowed EDVAC to be one of the very earliest Stored-Program Computers,
这使得 EDVAC 成为最早的 "存储程序计算机" 之一

which we talked about in Episode 10.
我们在第 10 集讨论过

However, a big drawback with delay line memory
但"延迟线存储器"的一大缺点是

is that you could only read one bit of data from a tube at any given instant.
每一个时刻只能读一位 (bit) 数据

If you wanted to access a specific bit, like bit 112,
如果想访问一个特定的 bit,比如第 112 位(bit) \N 你得等待它从循环中出现

you'd have to wait for it to come around in the loop,
如果想访问一个特定的 bit,比如第 112 位(bit) \N 你得等待它从循环中出现

what's called sequential or cyclic-access memory,
所以又叫 "顺序存储器"或"循环存储器"

whereas we really want random access memory,
而我们想要的是 "随机存取存储器" \N 可以随时访问任何位置

where we can access any bit at any time.
而我们想要的是 "随机存取存储器" \N 可以随时访问任何位置

It also proved challenging to increase the density of the memory,
增加内存密度也是一个挑战

packing waves closer together meant they were more easily mixed up.
把压力波变得更紧密 意味着更容易混在一起

In response, new forms of delay line memory were invented,
所以出现了其他类型的 "延迟线存储器"

such as magnetostrictive delay lines .
如 "磁致伸缩延迟存储器"

These delay lines use a metal wire that could be twisted,
用金属线的振动来代表数据

creating little torsional waves that represented data.
用金属线的振动来代表数据

By forming the wire into a coil, you could store around 1000 bits in a 1 foot by 1 foot square.
通过把线卷成线圈,1英尺×1英尺的面积能存储大概 1000位(bit)

However, delay line memory was largely obsolete by the mid 1950s,
然而,延迟线存储器在 1950 年代中期就基本过时了

surpassed in performance, reliability and cost by a new kid on the block:
因为出现了新技术,性能,可靠性和成本都更好

magnetic core memory which was constructed out of little magnetic donuts,
"磁芯存储器",用了像甜甜圈的小型磁圈

called cores.
"磁芯存储器",用了像甜甜圈的小型磁圈

If you loop a wire around this core.
如果给磁芯绕上电线,并施加电流,可以将磁化在一个方向

and run an electrical current through the wire,
如果给磁芯绕上电线,并施加电流,可以将磁化在一个方向

we can magnetize the core in a certain direction.
如果给磁芯绕上电线,并施加电流,可以将磁化在一个方向

If we turn the current off, the core will stay magnetized.
如果关掉电流,磁芯保持磁化

If we pass current through the wire in the opposite direction,
如果沿相反方向施加电流

the magnetization direction, called polarity,
磁化的方向(极性)会翻转

flips the other way.
磁化的方向(极性)会翻转

In this way, we can store 1's and 0's!
这样就可以存 1 和 0!

1 bit of memory isn't very useful, so these little donuts were arranged into grids.
如果只存 1 位不够有用,所以把小甜甜圈排列成网格

There were wires for selecting the right row and column, and a wire that ran through every core,
有电线负责选行和列 \N 也有电线贯穿每个磁芯, 用于读写一位(bit)

which could be used to read or write a bit.
有电线负责选行和列 \N 也有电线贯穿每个磁芯, 用于读写一位(bit)

Here is an actual piece of core memory!
我手上有一块磁芯存储器

In each of these little yellow squares, there are 32 rows and 32 columns of tiny cores,
每个黄色方格 有32行x32列的磁芯 \N 每个磁芯存 1 位数据

each one holding 1 bit of data.
每个黄色方格 有32行x32列的磁芯 \N 每个磁芯存 1 位数据

So, each of these yellow squares could hold 1024 bits.
所以能存 1024 位(bit) (32x32=1024)

In total, there are 9 of these,
总共 9 个黄色方格

so this memory board could hold a maximum of 9216 bits,
所以这块板子最多能存 9216 位(bit) (1024x9=9216)

which is around 9 kilobytes.
换算过来大约是 9 千字节 \N (9216 bit ~= 9 kb)

The first big use of core memory was MIT's Whirlwind 1 computer, in 1953,
磁芯内存的第一次大规模运用\N 是 1953 年麻省理工学院的 Whirlwind 1 计算机

which used a 32 by 32 core arrangement.
磁芯排列是 32×32

And, instead of just a single plane of cores, like this,
用了 16 块板子,能存储大约 16000 位(bit)

it was 16 boards deep, providing roughly 16 thousand bits of storage.
用了 16 块板子,能存储大约 16000 位(bit)

Importantly, unlike delay line memory,
更重要的是,不像"延迟线存储器" \N 磁芯存储器能随时访问任何一位(bit)

any bit could be accessed at any time.
更重要的是,不像"延迟线存储器" \N 磁芯存储器能随时访问任何一位(bit)

This was a killer feature,
这在当时非常了不起

and magnetic core memory became the predominant Random Access Memory technology
"磁芯存储器" 从 1950 年代中期开始成为主流 \N 流行了 20 多年

for two decades, beginning in the mid 1950
"磁芯存储器" 从 1950 年代中期开始成为主流 \N 流行了 20 多年

even though it was typically woven by hand!
而且一般还是手工编织的!

Although starting at roughly 1 dollar per bit,
刚开始时 存储成本大约 1 美元 1 位(bit) \N 到1970年代,下降到 1 美分左右

the cost fell to around 1 cent per bit by the 1970s.
刚开始时 存储成本大约 1 美元 1 位(bit) \N 到1970年代,下降到 1 美分左右

Unfortunately, even 1 cent per bit isn't cheap enough for storage.
不幸的是,即使每位 1 美分也不够便宜

As previously mentioned,
之前提过,现代手机随便拍张照片都有 5 MB

an average smartphone photo is around 5 megabytes in size,
之前提过,现代手机随便拍张照片都有 5 MB

that's roughly 40 million bits.
5MB 约等于 4000 万 bit

Would you pay 4 hundred thousand dollars to store a photo on core memory?
你愿意花 40 万美元在"磁芯存储器"上存照片吗?

If you have that kind of money to drop,
如果你有这么多钱

did you know that Crash Course is on Patreon?
你知道 Crash Course 在 Patreon 有赞助页吗?

Right? Wink wink.
对吧?你懂的

Anyway, there was tremendous research into storage technologies happening at this time.
总之,当时对存储技术进行了大量的研究

By 1951, Eckert and Mauchly had started their own company,
到 1951 年,Eckert 和 Mauchly 创立了自己的公司

and designed a new computer called UNIVAC,
设计了一台叫 UNIVAC 的新电脑

one of the earliest commercially sold computers.
最早进行商业销售的电脑之一

It debuted with a new form of computer storage:
它推出了一种新存储:磁带

magnetic tape.
它推出了一种新存储:磁带

This was a long, thin and flexible strip of magnetic material, stored in reels.
磁带是纤薄柔软的一长条磁性带子 卷在轴上

The tape could be moved forwards or backwards inside of a machine called a tape drive.
磁带可以在"磁带驱动器"内前后移动

Inside is a write head,
里面有一个"写头"绕了电线,电流通过产生磁场

which passes current through a wound wire to generate a magnetic field,
里面有一个"写头"绕了电线,电流通过产生磁场

causing a small section of the tape to become magnetized.
导致磁带的一小部分被磁化

The direction of the current sets the polarity, again, perfect for storing 1's and 0's.
电流方向决定了极性,代表 1 和 0

There was also a separate read head could detect the polarity non-destructively.
还有一个"读头",可以非破坏性地检测极性

The UNIVAC used half-inch-wide tape with 8 parallel data tracks,
UNIVAC 用了半英寸宽,8条并行的磁带

each able to store 128 bits of data per inch.
磁带每英寸可存 128 位数据

With each reel containing 1200 feet of tape,
每卷有 1200 英尺长

it meant you could store roughly 15 million bits
意味着一共可以存 1500 万位左右

  • that's almost 2 megabytes!
  • 接近2兆字节!(2 MB)

Although tape drives were expensive,
虽然磁带驱动器很贵,但磁带又便宜又小

the magnetic tape itself was cheap and compact,
虽然磁带驱动器很贵,但磁带又便宜又小

and for this reason, they're still used today for archiving data.
因此磁带至今仍用于存档

The main drawback is access speed.
磁带的主要缺点是访问速度

Tape is inherently sequential,
磁带是连续的,必须倒带或快进到达特定位置

you have to rewind or fast-forward to get to data you want.
磁带是连续的,必须倒带或快进到达特定位置

This might mean traversing hundreds of feet of tape to retrieve a single byte,
可能要几百英尺才能得到某个字节(byte),这很慢

which is slow.
可能要几百英尺才能得到某个字节(byte),这很慢

A related popular technology in the 1950s and 60s was Magnetic Drum Memory.
1950,60年代,有个类似技术是 "磁鼓存储器"

This was a metal cylinder - called a drum - coated in a magnetic material for recording data
有金属圆筒,盖满了磁性材料以记录数据

The drum was rotated continuously,
滚筒会持续旋转,周围有数十个读写头

and positioned along its length were dozens of read and write heads.
滚筒会持续旋转,周围有数十个读写头

These would wait for the right spot to rotate underneath them to read or write a bit of data.
等滚筒转到正确的位置\N 读写头会读或写 1 位(bit) 数据

To keep this delay as short as possible,
为了尽可能缩短延迟, 鼓轮每分钟上千转!

drums were rotated thousand of revolutions per minute!
为了尽可能缩短延迟, 鼓轮每分钟上千转!

By 1953, when the technology started to take off,
到 1953 年,磁鼓技术飞速发展 \N 可以买到存 80,000 位的"磁鼓存储器"

you could buy units able to record 80,000 bits of data
到 1953 年,磁鼓技术飞速发展 \N 可以买到存 80,000 位的"磁鼓存储器"

  • that's 10 kilobytes,
  • 也就是 10 KB

but the manufacture of drums ceased in the 1970s.
但到 1970 年代 "磁鼓存储器" 不再生产

However, Magnetic Drums did directly lead to the development of Hard Disk Drives,
然而,磁鼓导致了硬盘的发展 \N 硬盘和磁鼓很相似

which are very similar, but use a different geometric configuration.
然而,磁鼓导致了硬盘的发展 \N 硬盘和磁鼓很相似

Instead of large cylinder, hard disks use,
不过硬盘用的是盘,不像磁鼓用圆柱体,因此得名

well disks that are hard.
不过硬盘用的是盘,不像磁鼓用圆柱体,因此得名

Hence the name!
不过硬盘用的是盘,不像磁鼓用圆柱体,因此得名

The storage principle is the same,
原理是一样的,磁盘表面有磁性

the surface of a disk is magnetic,
原理是一样的,磁盘表面有磁性

allowing write and read heads to store and retrieve 1's and 0's.
写入头和读取头 可以处理上面的 1 和 0

The great thing about disks is that they are thin,
硬盘的好处是薄,可以叠在一起

so you can stack many of them together,
硬盘的好处是薄,可以叠在一起

providing a lot of surface area for data storage.
提供更多表面积来存数据

That's exactly what IBM did for the world's first computer with a disk drive:
IBM 对世上第一台磁盘计算机就是这样做的

the RAMAC 305.
RAMAC 305

Sweet name BTW.
顺便一说名字不错

It contained fifty, 24-inch diameter disks,
它有 50 张 24 英寸直径的磁盘,总共能存 5 MB 左右

offering a total storage capacity of roughly 5 megabytes.
它有 50 张 24 英寸直径的磁盘,总共能存 5 MB 左右

Yess!! We've finally gotten to a technology that can store a single smartphone photo!
太棒啦! 终于能存一张现代手机的照片了!这年是 1956 年

The year was 1956.
太棒啦! 终于能存一张现代手机的照片了!这年是 1956 年

To access any bit of data,
要访问某个特定 bit

a read/write head would travel up or down the stack to the right disk,
一个读/写磁头会向上或向下移动,找到正确的磁盘

and then slide in between them.
然后磁头会滑进去

Like drum memory, the disks are spinning,
就像磁鼓存储器一样,磁盘也会高速旋转

so the head has to wait for the right section to come around.
所以读写头要等到正确的部分转过来

The RAMAC 305 could access any block of data, on average, in around 6/10ths of a second,
RAMAC 305 访问任意数据,平均只要六分之一秒左右

what's called the seek time.
也叫寻道时间

While great for storage, this was not nearly fast enough for memory,
虽然六分之一秒对存储器来说算不错 \N 但对内存来说还不够快

so the RAMAC 305 also had drum memory and magnetic core memory.
所以 RAMAC 305 还有"磁鼓存储器"和"磁芯存储器"

This is an example of a memory hierarchy,
这是"内存层次结构"的一个例子

where you have a little bit of fast memory, which is expensive,
一小部分高速+昂贵的内存

slightly more medium-speed memory, which is less expensive,
一部分稍慢+相对便宜些的内存

and then a lot of slowish memory, which is cheap.
还有更慢+更便宜的内存

This mixed approach strikes a balance between cost and speed.
这种混合 在成本和速度间取得平衡

Hard disk drives rapidly improved and became commonplace by the 1970s.
1970 年代,硬盘大幅度改进并变得普遍

A hard disk like this can easily hold 1 terabyte of data today
如今的硬盘可以轻易容纳 1TB 的数据

  • that's a trillion bytes - or roughly 200,000 five megabyte photos!
    能存 20 万张 5MB 的照片!

And these types of drives can be bought online for as little as 40 US dollars.
网上最低 40 美元就可以买到

That's 0.0000000005 cents per bit.
每 bit 成本 0.0000000005 美分

A huge improvement over core memory's 1 cent per bit!
比磁芯内存 1 美分 1 bit 好多了!

Also, modern drives have an average seek time of under 1/100th of a second.
另外,现代硬盘的平均寻道时间低于 1/100 秒

I should also briefly mention a close cousin of hard disks, the floppy disk,
我简单地提一下硬盘的亲戚,软盘

which is basically the same thing, but uses a magnetic medium that's, floppy.
除了磁盘是软的,其他基本一样

You might recognise it as the save icon on some of your applications,
你可能见过某些程序的保存图标是一个软盘

but it was once a real physical object!
软盘曾经是真实存在的东西!

It was most commonly used for portable storage,
软盘是为了便携,在 1970~1990 非常流行

and became near ubiquitous from the mid 1970s up to the mid 90s.
软盘是为了便携,在 1970~1990 非常流行

And today it makes a pretty good coaster.
如今当杯垫挺不错的

Higher density floppy disks, like Zip Disks,
密度更高的软盘,如 Zip Disks,在90年代中期流行起来

became popular in the mid 1990s,
密度更高的软盘,如 Zip Disks,在90年代中期流行起来

but fell out of favor within a decade.
但十年内就消失了

Optical storage came onto the scene in 1972, in the form of a 12-inch "laser disc."
光学存储器于 1972 年出现,12 英寸的"激光盘"

However, you are probably more familiar with its later, smaller, are more popular cousin,
你可能对后来的产品更熟:光盘(简称 CD)

the Compact Disk, or CD,
你可能对后来的产品更熟:光盘(简称 CD)

as well as the DVD which took off in the 90s.
以及 90 年代流行的 DVD

Functionally, these technologies are pretty similar to hard disks and floppy disks,
功能和硬盘软盘一样,都是存数据.

but instead of storing data magnetically,
但用的不是磁性

optical disks have little physical divots in their surface that cause light to be reflected differently,
光盘表面有很多小坑,造成光的不同反射

which is captured by an optical sensor, and decoded into 1's and 0's.
光学传感器会捕获到,并解码为 1 和 0

However, today, things are moving to solid state technologies, with no moving parts,
如今,存储技术在朝固态前进,没有机械活动部件

like this hard drive and also this USB stick.
比如这个硬盘,以及 U 盘

Inside are Integrated Circuits,
里面是集成电路,我们在第 15 集讨论过

which we talked about in Episode 15.
里面是集成电路,我们在第 15 集讨论过

The first RAM integrated circuits became available in 1972 at 1 cent per bit,
第一个 RAM 集成电路出现于 1972 年 \N 成本每比特 1 美分

quickly making magnetic core memory obsolete.
使"磁芯存储器"迅速过时

Today, costs have fallen so far,
如今成本下降了更多 \N 机械硬盘 被 固态硬盘 逐渐替代,简称 SSD

that hard disk drives are being replaced with non-volatile,
如今成本下降了更多 \N 机械硬盘 被 固态硬盘 逐渐替代,简称 SSD

Solid State Drives, or SSDs, as the cool kids say.
如今成本下降了更多 \N 机械硬盘 被 固态硬盘 逐渐替代,简称 SSD

Because they contain no moving parts,
由于 SSD 没有移动部件

they don't really have to seek anywhere,
磁头不用等磁盘转

so SSD access times are typically under 1/1000th of a second.
所以 SSD 访问时间低于 1/1000 秒

That's fast!
这很快!

But it's still many times slower than your computer's RAM.
但还是比 RAM 慢很多倍

For this reason, computers today still use memory hierarchies.
所以现代计算机 仍然用存储层次结构

So, we've come along way since the 1940s.
我们从 1940 年代到现在进步巨大

Much like transistor count and Moore's law,
就像在第 14 集讨论过的 晶体管数量和摩尔定律

which we talked about in Episode 14,
就像在第 14 集讨论过的 晶体管数量和摩尔定律

memory and storage technologies have followed a similar exponential trend.
内存和存储技术也有类似的趋势

From early core memory costing millions of dollars per megabyte, we're steadily fallen,
从早期每 MB 成本上百万美元,下滑到

to mere cents by 2000, and only fractions of a cent today.
2000 年只要几分钱,如今远远低于 1 分钱

Plus, there's WAY less punch cards to keep track of.
完全没有打孔纸卡

Seriously, can you imagine if there was a slight breeze in that room containing the SAGE program?
你能想象 SEGA 的纸卡房间风一吹会怎样吗?

62,500 punch cards.
62,500 张卡

I don't even want to think about it.
我想都不敢想

I'll see you next week.
我们下周见

标签: video