Computer Science IGCSE หัวข้อ 3 11:52 บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
บท
Transcript
The processor in your phone is doing something almost stupidly simple.
你手机里的处理器,做的其实是一件简单到近乎笨拙的事。
Fetch one instruction.
取出一条指令。
Work out what it means.
弄清楚它是什么意思。
Do it.
执行它。
Then fetch the next one.
然后再取下一条。
That is the whole job.
这就是它的全部工作。
What makes it feel clever is speed — it repeats that loop billions of times every second.
让它显得聪明的,是速度—— 它每秒钟要把这个循环重复几十亿次。
So if you want to understand a computer, you really only need to understand one small loop, and the handful of tiny stores that make it work.
所以,如果你想弄懂一台计算机, 你真正需要弄懂的,只是一个很小的循环,以及那几个让它转起来的微小存储器。
Inside the computer.
走进计算机内部。
Today: the parts of the processor, the special registers, the fetch-decode-execute cycle, what makes a processor fast, input and output devices, RAM and ROM, secondary storage, virtual memory, the cloud, and network hardware.
今天我们讲:处理器的各个组成部分、几个专用寄存器、取指—译码—执行周期、 是什么让处理器更快、输入和输出设备、RAM 与 ROM、辅助存储器、虚拟内存、云存储,以及网络硬件。
Let's begin.
让我们开始吧。
This is what a central processing unit looks like as a chip.
这就是中央处理器做成芯片时的样子。
It is the part of the computer that processes data and carries out instructions.
它是计算机里处理数据、执行指令的那一部分。
Every program you run is broken into tiny steps, and the processor repeats those steps millions or billions of times each second.
你运行的每一个程序都会被拆成极小的步骤,处理器每秒钟要把这些步骤重复几百万次甚至几十亿次。
The metal lid and the pins underneath hide the arithmetic unit, the control unit, and the registers we are about to open up.
金属盖和下面的引脚里,藏着我们马上要拆开讲的算术单元、控制单元和寄存器。
The central processing unit has three main parts.
中央处理器有三个主要部分。
The arithmetic logic unit does the calculations — adding, subtracting — and the logical operations, like comparing two values.
算术逻辑单元负责计算——加法、减法——以及逻辑运算,比如比较两个值。
The control unit sends control signals to every other part, telling each one what to do and when.
控制单元向其他每一个部件发出控制信号,告诉它们该做什么、什么时候做。
And the registers are very small, very fast stores, each holding one piece of data at a time.
而寄存器是非常小、非常快的存储器,每个一次只装一份数据。
Those parts are joined to memory by three buses — sets of wires.
这些部件通过三条总线——也就是成组的导线——和内存连接起来。
The address bus carries memory addresses, and it goes one way only.
地址总线传送内存地址,只能单向。
The data bus carries data and instructions, and it goes both ways.
数据总线传送数据和指令,可以双向。
And the control bus carries the control signals.
而控制总线传送的是控制信号。
Here is that idea as a block diagram.
这就是同一想法的框图。
Inside the processor sit the control unit, the arithmetic logic unit, and the registers.
处理器内部是控制单元、算术逻辑单元和寄存器。
Outside is main memory.
外面是主内存。
Three buses join them.
三条总线把它们连在一起。
The address bus points at a location — one way only, from the processor out.
地址总线指向一个位置——只能从处理器向外,单向。
The data bus carries the value found there, or a value to write back — both directions.
数据总线运送在那里找到的值,或要写回去的值——双向。
The control bus carries the signals that say read, write, or wait.
控制总线运送读、写或等待之类的信号。
If an exam asks how the processor talks to memory, name these three buses and the direction each one runs.
如果考试问处理器怎样和内存通信,就说出这三条总线,以及每一条的方向。
Five registers do the real work of the cycle, and the exam asks for them by name.
有五个寄存器承担了这个周期里真正的工作,而且考试会点名要你说出它们。
The program counter holds the address of the next instruction — the next one, not the one running now.
程序计数器保存的是下一条指令的地址——是下一条,不是正在运行的这一条。
The memory address register holds the address the processor wants to read from or write to.
内存地址寄存器保存处理器要读取或写入的那个地址。
The memory data register holds the data or instruction that was just fetched.
内存数据寄存器保存刚刚取回来的数据或指令。
The current instruction register holds the instruction being carried out right now.
当前指令寄存器保存的是此刻正在执行的那条指令。
And the accumulator holds the result of the arithmetic logic unit's calculation.
而累加器保存算术逻辑单元算出来的结果。
Now watch them work together.
现在来看它们是怎么配合的。
Fetch: the program counter's address is copied into the memory address register.
取指:程序计数器里的地址被复制到内存地址寄存器。
The instruction stored at that address travels back along the data bus into the memory data register, and from there into the current instruction register.
存放在那个地址上的指令,沿着数据总线送回内存数据寄存器,再从那里进入当前指令寄存器。
The program counter then increases by one, ready for next time.
接着程序计数器加一,为下一次做好准备。
Decode: the control unit works out what that instruction actually means.
译码:控制单元弄清楚这条指令到底是什么意思。
Execute: the instruction is carried out — and if it is a calculation, the arithmetic logic unit does it and puts the answer into the accumulator.
执行:指令被真正执行——如果它是一次计算,算术逻辑单元就把它算出来, 并把答案放进累加器。
Then the whole thing begins again.
然后整件事再重新开始。
Fetch, decode, execute, over and over.
取指、译码、执行,一遍又一遍。
So what makes one processor faster than another?
那么,是什么让一个处理器比另一个更快呢?
Three things.
有三件事。
The number of cores: each core can run instructions on its own, so more cores can do more work at the same time.
核心数量:每个核心都能独立运行指令, 所以核心越多,同一时间能干的活就越多。
The size of the cache — cache is a small amount of very fast memory right beside the processor, holding the data it uses most, so it waits less for main memory.
缓存大小——缓存是紧挨着处理器的一小块极快的内存, 装着它最常用的数据,这样它等待主内存的时间就更短。
And the clock speed: the number of cycles per second, so a higher clock speed runs more instructions each second.
还有时钟速度:每秒的周期数, 所以时钟速度越高,每秒执行的指令就越多。
Now a warning.
现在提个醒。
Computer A has a three gigahertz single core with two megabytes of cache.
计算机 A 是三吉赫兹单核, 带两兆字节缓存。
Computer B has a two point four gigahertz quad core with eight megabytes of cache.
计算机 B 是二点四吉赫兹四核,带八兆字节缓存。
Which is better for video editing?
哪一台更适合剪辑视频?
B — because video editing splits into many tasks that run at the same time, so four cores beat one, and the bigger cache means fewer trips out to memory.
是 B——因为视频剪辑会拆成很多可以同时进行的任务,四个核心胜过一个, 而更大的缓存也意味着更少地跑去内存取数据。
Never answer on clock speed alone.
千万不要只看时钟速度就作答。
One special case: an embedded system.
还有一种特殊情况:嵌入式系统。
That is a small computer built inside a larger device, to do one fixed job.
它是一台装在更大设备内部的小型计算机,只做一件固定的工作。
It is dedicated to that task, it is usually small and low-cost, and it has no general operating system — you cannot install other programs onto it.
它专门服务于那一项任务,通常体积小、成本低,而且没有通用的操作系统—— 你没法在上面安装别的程序。
A washing machine, a microwave, a set-top box: each one has a processor inside it, doing exactly one job, for ever.
洗衣机、微波炉、机顶盒: 每一个里面都有一个处理器,永远只做那一件事。
Devices split into two groups.
设备分成两大类。
Input devices send data into the computer.
输入设备把数据送进计算机。
A barcode scanner shines light at the bars and reads the pattern reflected back.
条形码扫描器向条纹照射光线,读取反射回来的图案。
A keyboard sends a code for each key pressed.
键盘为每一次按键送出一个编码。
An optical mouse tracks movement with a light and a sensor.
光电鼠标靠一束光和一个传感器来追踪移动。
A microphone turns sound into an electrical signal.
麦克风把声音变成电信号。
Sensors measure a physical quantity, like temperature or light.
传感器测量某个物理量,比如温度或光照。
And a touch screen detects where your finger is, in one of three ways: resistive, where two layers press together. Capacitive, which senses your finger's tiny electric charge. And infrared, where your finger breaks a grid of light beams.
而触摸屏检测你的手指在哪里,方式有三种:电阻式,靠两层被按到一起; 电容式,感应你手指上那一点点电荷;还有红外式,靠你的手指挡住一格一格的光束。
Output devices send data out to the user — screens, projectors, speakers, inkjet and laser printers, three-D printers, and actuators, which turn an electrical signal into movement, like a motor or a valve.
输出设备则把数据送出去给用户——显示屏、投影仪、扬声器、喷墨和激光打印机、 三维打印机,还有执行器,它把电信号变成运动,比如电机或者阀门。
Primary storage is memory the processor can use directly, and there are two kinds.
主存储器是处理器可以直接使用的内存,它有两种。
RAM — random access memory — can be both read and written, and it is volatile: switch the power off, and everything in it is gone.
RAM——随机存取存储器——既能读也能写, 而且它是易失性的:一断电,里面的一切就没了。
It holds the programs and the data you are using right now.
它装的是你此刻正在用的程序和数据。
ROM — read only memory — can only be read, and it is non-volatile: it keeps its contents with no power at all.
ROM——只读存储器——只能读,而且它是非易失性的:完全没有电,它也能保住里面的内容。
It holds the start-up instructions that tell the computer how to boot.
它装的是告诉计算机怎么启动的那些开机指令。
You need both: ROM starts the machine, and then RAM holds whatever you run.
两者你都需要: ROM 把机器启动起来,然后 RAM 装下你运行的一切。
Secondary storage keeps data permanently, even with the power off, and there are three types.
辅助存储器把数据永久地保存下来,即使断电也不会丢,它有三种类型。
Magnetic storage keeps data as magnetised spots on spinning disks — a hard disk drive, or magnetic tape for cheap backups.
磁存储把数据保存成旋转磁盘上被磁化的小点——比如硬盘,或者用来做廉价备份的磁带。
Optical storage keeps data as marks read by a laser — CDs, DVDs and Blu-ray.
光存储把数据保存成由激光读取的痕迹——比如 CD、DVD 和蓝光。
And solid state storage keeps data in flash memory, with no moving parts at all — an SSD, a USB stick, a memory card.
而固态存储把数据保存在闪存里,完全没有活动部件——比如固态硬盘、U 盘、存储卡。
If the exam asks you to match a device to a type, look for the mechanism: a spinning disk, a laser, or flash.
如果考试让你把某个设备归到某一类,就去找它的机制:是旋转的磁盘、激光,还是闪存。
Put all of that memory in order and you get a hierarchy.
把这些存储器按顺序排好,就得到一个层级结构。
At the top, registers — tiny, and the fastest thing in the whole machine.
最上面是寄存器——很小, 但也是整台机器里最快的东西。
Then cache.
接着是缓存。
Then RAM.
然后是 RAM。
Then secondary storage at the bottom: enormous, but by far the slowest.
最底下是辅助存储器: 容量极大,但慢得多。
As you go down, it gets bigger and cheaper — and slower.
越往下走,容量越大、越便宜——也越慢。
That last step matters, because of virtual memory.
最后这一步很关键,因为它牵涉到虚拟内存。
When RAM fills up, the computer moves data it is not using right now out of RAM and onto the disk, freeing space.
当 RAM 快满了, 计算机会把此刻用不到的数据从 RAM 搬到磁盘上,腾出空间。
That lets you run more programs than the RAM alone could hold — but because the disk is so much slower, everything slows down.
这让你能运行比 RAM 本身装得下的更多程序——但因为磁盘慢太多,整体速度就会下降。
When random access memory fills up, the computer can use part of secondary storage as extra pretend memory.
当随机存取存储器快满了,计算机可以把一部分辅助存储器当作额外的假内存来用。
That is virtual memory.
这就是虚拟内存。
Data not needed right now is moved out of random access memory onto the disk, freeing space for other programs.
此刻用不到的数据被从随机存取存储器搬到磁盘上,腾出空间给其他程序。
You can run more than the random access memory alone could hold.
你能运行比随机存取存储器本身装得下的更多程序。
The cost is speed: secondary storage is much slower, so the machine may thrash — keep swapping data in and out — and everything feels sluggish until you close programs or add more memory.
代价是速度:辅助存储器慢得多, 机器可能不停地把数据换进换出,一切都会感觉迟钝,直到你关掉一些程序,或加装更多内存。
Cloud storage keeps your files on remote servers, reached over the internet, instead of on your own device. The advantages: you can reach them from anywhere, on any device. You buy and maintain no storage hardware yourself. And sharing files and backing up automatically are both easy. The disadvantages: you need a working internet connection. There is usually an ongoing subscription cost. Your security and privacy depend on the provider. And you are relying on that provider staying available, and staying in business.
云存储把你的文件放在远程服务器上,通过互联网访问,而不是存在你自己的设备里。 好处是:你可以在任何地方、用任何设备访问它们;你不用自己购买和维护存储硬件; 而且共享文件和自动备份都很方便。 坏处是:你需要一条能用的网络连接; 通常还有持续的订阅费用;你的安全和隐私取决于服务商; 而且你还得指望那家服务商一直在线,并且一直经营下去。
Last, the hardware that puts a computer on a network.
最后是让计算机接入网络的那些硬件。
A network interface card is what lets a device join a network at all, and every one of them has a MAC address built in.
网络接口卡是让设备能够加入网络的关键, 而且每一块上面都内置了一个 MAC 地址。
Now the distinction the exam loves.
现在说考试最爱考的那个区分。
A MAC address identifies one physical device: the maker sets it, it is written in hexadecimal, and it does not normally change.
MAC 地址标识的是一台具体的物理设备:由厂商设定,用十六进制书写,通常不会改变。
An IP address identifies a device on a network: the network hands it out, and it can change.
IP 地址标识的是网络上的一台设备:由网络分配,并且是会变的。
So the MAC address travels with the device, while the IP address depends on where that device is.
所以 MAC 地址跟着设备走, 而 IP 地址取决于这台设备在哪里。
IP addresses come in two versions — IPv4, thirty-two bits, written as four numbers from zero to two hundred and fifty-five; and IPv6, one hundred and twenty-eight bits, written in hexadecimal, giving vastly more addresses.
IP 地址有两个版本——IPv4,三十二位, 写成四个从零到二百五十五的数字;还有 IPv6,一百二十八位,用十六进制书写, 能提供多得多的地址。
And a router connects different networks together, reading the IP address in each packet and forwarding it towards the right network.
而路由器把不同的网络连接起来, 读取每个数据包里的 IP 地址,再把它转发到正确的网络去。
A router connects different networks together — for example your home network to the internet.
路由器把不同的网络连接起来——比如你家的网络和互联网。
It reads the internet protocol address in each packet and forwards the packet towards the right network.
它读取每个数据包里的网际协议地址,再把数据包转发到正确的网络去。
A home Wi-Fi box is usually a router plus a wireless access point in one case.
家用无线盒子通常是路由器和无线接入点装在同一个外壳里。
Without a router, devices on your local network cannot reach other networks at all.
没有路由器,你本地网上的设备就完全到不了其他网络。
An internet protocol address is also either static or dynamic.
网际协议地址还有静态和动态之分。
Static means fixed: set by hand and it does not change.
静态是固定的:人手设定,不会变。
Dynamic means the router or network hands a new address out each time the device connects, so it can change.
动态是路由器或网络在设备每次接入时重新分配,所以会变。
Servers that must stay easy to find often use a static address.
必须容易被找到的服务器常常用静态地址。
Phones and laptops on home Wi-Fi usually get a dynamic one.
家里无线网上的手机和笔记本通常拿到动态地址。
Remember the other pair too: a media access control address stays with the physical device; an internet protocol address depends on the network.
还要记住另一对:介质访问控制地址跟着物理设备;网际协议地址取决于所在网络。
Four marks to lock in.
四个要拿稳的分。
First, the program counter holds the address of the next instruction — not the one running now.
第一,程序计数器保存的是下一条指令的地址——不是正在运行的那一条。
Second, weigh cores, cache and clock speed together, never clock speed alone.
第二,把核心数、缓存和时钟速度放在一起权衡,绝不能只看时钟速度。
Third, RAM is volatile and holds what is running, while ROM is non-volatile and read-only.
第三,RAM 是易失性的,装着正在运行的东西;而 ROM 是非易失性的,并且只读。
Fourth, a MAC address stays with the device, but an IP address is given by the network and can change.
第四,MAC 地址跟着设备走,而 IP 地址由网络分配,是会变的。
Nail these, and this topic is yours.
掌握这些,这个专题就是你的了。
ความคิดเห็น (Comments)
ยังไม่มีความคิดเห็น เป็นคนแรกที่ถามหรือแบ่งปันเรื่องราว