字幕列表 影片播放
Do you remember when you first realized
你還記得你首先領悟到
that your computer was more
的電腦不只是
than just a monitor and keyboard?
螢幕加鍵盤而已嗎?
That between the mouse click and the video playing,
滑鼠點兩下,影片就開始播放
there was something that captured your intention,
在這之間有樣東西,得知你的意圖
understood it,
予以解讀
and made it real?
並讓它實現
What is that something?
這東西是什麼?
Is it gremlins?
是小妖精嗎?
Let's imagine that we can shrink down
想像一下,我們縮小到
to the size of an electron
和電子一樣的大小
and inject ourselves into a click of a mouse.
接著把自己注射到滑鼠鍵裡
If you took your mouse apart,
如果你把滑鼠拆開
you'd see that it's really a very simple machine.
你會發現這是很簡單的機器
It has a couple buttons
滑鼠有兩個按鍵
and a system for detecting motion and distance.
一個偵測動向及距離的系統
You might have an optical mouse
你可能用的是光學滑鼠
that makes these measurements with lights and sensors,
透過光及感應器來完成這些計算
but older ones did this with a hard rubber ball
舊一點的滑鼠有一顆硬硬的橡膠球
and some plastic wheels.
還有塑膠環
Same concept.
兩者概念相同
When you click the button on your mouse,
當你按下滑鼠按鍵的時候
it sends a message to the computer
滑鼠就發送訊息到電腦
with information about its position.
關於滑鼠位置的資訊
When your mouse click is received,
電腦接收滑鼠資訊後
it's handled by the basic input/output subsystem.
則由輸出入的子系統來負責
This subsystem acts like the eyes and ears
這個子系統就像是電腦的眼睛
and mouth and hands of the computer.
耳朵、嘴巴,以及雙手
Basically, it provides a way for the computer
基本上,這個系統提供電腦一個方法
to interact with its environment.
去和電腦環境互動
But it also acts like a buffer
它的作用也有點像緩衝器
to keep the CPU from being overwhelmed by distractions.
避免CPU被不相干的程式淹沒
In this case, the I/O subsystem decides
就這例子來看,輸出入子系統
that your mouse click is pretty important
判定滑鼠點選的項目很重要
so it generates an interrupt to the CPU.
所以發送一個插播信號給CPU
"Hey, CPU! Got a click here."
「嘿,CPU!這東西被點選了。」
The CPU, or central processing unit,
CPU,也就是中央處理器
is the brains of the whole computer.
是整台電腦的大腦
Just like your brain doesn't take up your whole body,
就像你的大腦不會占據你全身
the CPU doesn't take up the whole computer,
CPU也不會占據整台電腦
but it runs the show all the same.
但是他會一直執行同樣的事情
And the CPU's job, its whole job,
CPU的主要工作
is fetching instructions from memory
就是從記憶體拿取指示
and executing them.
然後執行
So, while you're typing, typing, typing,
所以當你不斷打字
maybe really fast,
也許打得很快
like 60 words a minute,
一分鐘六十個字吧
the CPU is fetching and executing
CPU一直拿取然後執行
billions of instructions a second.
一秒鐘執行數十億個指示
Yes, billions every second:
對,每秒鐘幾十億個
instructions to move your mouse around on the screen,
你在螢幕上移動滑鼠的指示
to run that clock widget on your desktop,
執行桌面的時鐘附件
play your internet radio,
播放網路電台
manage the files you're editing on the hard drive,
處理在硬碟中,你在編輯的檔案
and much, much more.
還有很多很多
Your computer's CPU is one heck of a multitasker!
CPU就是個超神的多重任務處理王
"But oh my gosh
「但是我的天呀
there's a very important mouse click
滑鼠點了一下
coming through now!
資訊現在要傳來了!
Let's drop everything now and deal with that!"
先停止所有任務,然後處理那個!」
There are programs for everything
CPU處理的每樣事物
that the CPU does.
都有一個程式
A special program for the mouse,
滑鼠有個專門的程式
for the clock widget,
時鐘附件也有
for the internet radio,
網路電台也有
and for dealing with letters sent by the keyboard.
處理鍵盤傳送的文字也有
Each program was initially written by a human
每個程式一開始都是人類寫的
in a human-readable programming language,
用人類看得懂的程式語言
like Java,
像是Java
C++,
C++
or Python.
或是Python
But human programs take up a lot of space
但是人類的程式占據了很多空間
and contain a lot of unnecessary information to a computer,
也包含很多電腦不需要的程式
so they are compiled and made smaller
這些程式因而被整合,縮小
and stored in bits of ones and zeros in memory.
以1和0的方式儲存在記憶體中
The CPU realizes that it needs instructions
CPU知道自己需要指示
for how to deal with this mouse click,
去處理滑鼠點的那一下
so it looks up the address for the mouse program
所以CPU就查詢滑鼠的程式
and sends a request to the memory subsystem
並發送請求給記憶體的子系統
for instructions stored there.
讀取儲存在那的指示
Each instruction in the mouse device driver
滑鼠驅動程式的每一個指示
is duly fetched and executed.
都能充分拿取並執行
And that's not nearly the end of the story!
還不僅僅如此!
Because the CPU learns that the mouse was clicked
因為CPU知道滑鼠被按了一下
when the cursor was over a picture
游標經過某張圖片
of a button on the monitor screen,
在顯示器某個按鈕的時候
and so, the CPU asks memory for the monitor program
CPU會要求記憶體提供顯示器的程式
to find out what that button is.
找出滑鼠是按了哪裡
And then the CPU has to ask memory
然後CPU得要求記憶體
for the program for the button,
提供按鍵的程式
which means that the CPU needs
也就是說,CPU還需要
the monitor program again
顯示器的程式
to show the video associated with the button,
顯示出影片與按鍵的關聯性
and so it goes.
影片就開始播放
And let's just say there are a lot of programs involved
我們假設過程中包含很多程式
before you even see the button on the screen
甚至在看到幕上的點選物
light up when you clicked it.
亮起來之前
So, just the simple task of clicking your mouse
所以,單純按下滑鼠這個動作
means visiting all of the critical components
代表你已經使用電腦結構中
of your computer's architecture:
許多重要的元素
peripherals,
像是週邊設備
the basic input-output system,
基本的輸出入系統
the CPU,
CPU
programs,
程式
and memory,
還有記憶體
and not one gremlin.
而不是小妖精