パフォーマンス、フェチ・エグゼキューションサイクル、割り込み
導入済み
21:25
Von Neumannアーキテクチャ
歴史の大部分において、機械は1つの作業しか行いませんでした。織機は布を織り、電卓は足し算をしました。新しいことをさせるには、再構築する必要がありました。そして、巧妙に単純な…が訪れました。
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| processor/ˈprəʊsesə/ | The component that executes instructions and performs the operations of a computer or similar system. |
| cycles | Repeated sequences of steps the processor follows to fetch and execute instructions. |
| instruction/ɪnˈstrʌkʃn/ | A command that tells the processor what action to perform. |
| interrupt/ˈɪntərʌpt/ | 割り込み |
| Clock speed/klɒk spiːd/ | More fetch-execute cycles a second, so more instructions a second, until heat sets the limit. |
| Execute/ˈeksɪkjuːt/ | Arithmetic and logic go to the ALU with the result in the ACC. |
| Number of cores/ˈnʌmbə ɒv kɔːz/ | The total count of independent processing units in a processor. |
| threads | Separate sequences of instructions that a processor can run independently. |
| parallel/ˈpærəlel/ | Describing operations that take place concurrently rather than one after another. |
| cores/kɔːz/ | コア |
| Bus width | A wider data bus moves more bits per transfer, so fewer transfers. |
| data bus/ˈdeɪtə bʌs/ | The signal lines carrying data between processor, memory and other connected components. |
| bits/bɪts/ | A binary digit, taking the value zero or one. |
| address bus/əˈdres bʌs/ | The signal lines used to identify a memory location or device involved in a transfer. |
| memory/ˈmeməri/ | Circuits that store data, such as registers, RAM and ROM. |
| Cache/kæʃ/ | A small, fast memory next to the processor holding the instructions and data used most recently, so fewer slow trips to RAM . Word size , the amount of RAM and the storage type help too. |
| RAM/ræm/ | Random-access memory used for working data and instructions, usually losing its contents when power is removed. |
| Word size/wɜːd saɪz/ | The number of bits a processor can handle as one unit. |
| working set | The instructions and data a program is currently using or likely to need. |
| port/pɔːt/ | ポート |
| peripheral/pəˈrɪfərəl/ | 周辺機器 |
| USB | A general-purpose connection for transferring data and supplying power to devices. |
| plug-and-play | Describes a device that a computer detects and sets up automatically. |
| load/ləʊd/ | To move data or a program into memory or a register. |
| driver/ˈdraɪvə/ | Software that allows the operating system to communicate with a device. |
| HDMI | A connection that carries digital video and audio through one cable. |
| digital video | Moving images represented by numbers that a computer can process. |
| audio | Sound represented as a signal that can be stored or transmitted. |
| analogue/ˈænəlɒɡ/ | Describes a signal that changes continuously and can take any value within a range. |
| VGA | An older connection that carries analogue video to a display. |
| fetch-execute cycle/fetʃ ˈeksɪkjuːt ˈsaɪkl/ | 取指-実行サイクル |
| register transfer notation/ˈredʒɪstə ˈtrænsfɜː nəʊˈteɪʃn/ | レジスタ転送記法 |
| read signal | A signal telling memory to send back data from a given address. |
| control bus/kənˈtrəʊl bʌs/ | The signal lines carrying control and timing information, such as read, write or interrupt signals. |
| address/əˈdres/ | An identifier specifying a location in memory or on a network. |
| PC | A register holding the address of the next instruction to fetch. |
| jump/dʒʌmp/ | An instruction that changes the address of the next instruction to fetch. |
| MAR | A register holding the address of a memory location being accessed. |
| MDR | A register holding data being transferred to or from memory. |
| CIR | A register holding the current instruction while it is decoded and executed. |
| Decode | The control unit works out from the instruction in the CIR which operation it is and where its operands are. |
| control unit/kənˈtrəʊl ˈjuːnɪt/ | The part of the processor that decodes instructions and controls their execution. |
| operation/ˌɒpəˈreɪʃn/ | The action that an instruction tells the processor to perform. |
| operands | Values used by an operation to produce a result. |
| arithmetic/əˈrɪθmətɪk/ | Calculations with numbers, such as adding and subtracting. |
| logic/ˈlɒdʒɪk/ | Operations that use rules to combine or change binary values. |
| ALU/ˌeɪ el ˈjuː/ | The part of a processor that performs arithmetic and logical operations. |
| ACC | A register that holds results of arithmetic and logic operations. |
| store/stɔː/ | To move data from a register into a memory location. |
| register/ˈredʒɪstə/ | A small, fast storage location within a processor used to hold data, addresses or instructions temporarily. |
| memory location | A place in memory that holds data and has an address. |
| signal/ˈsɪɡnl/ | Information or cues that communicate a condition and can influence a response or decision. |
| buffer/ˈbʌfə/ | A temporary area of memory used to hold data while it is transferred or processed. |
| network packet | A small unit of data sent across a computer network. |
| software fault | An error in software that causes a problem during a program's execution. |
| illegal instruction | An instruction that the processor cannot recognise or is not allowed to execute. |
| arithmetic overflow | A result that is too large or small for the available number of bits. |
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| timer/ˈtaɪmə/ | A hardware counter in a microcontroller used to measure time or produce regular events. |
| time slice/taɪm slaɪs/ | A short interval of processor time allocated to a task before another task may run. |
| multitasks | Runs multiple tasks by switching between them so they appear to run together. |
| state/steɪt/ | The saved information needed to continue a program from its current point. |
| stack/stæk/ | スタック |
| interrupt service routine/ˈɪntərʌpt ˈsɜːvɪs ruːˈtiːn/ | 割り込みサービスルーチン |
| input device/ˈɪnpʊt dɪˈvaɪs/ | A device that sends data or instructions to a computer for processing. |
| interrupt signal | A signal that asks the processor to respond to an event. |
| flag/flæɡ/ | A bit that records whether a particular condition or event has occurred. |
| interrupt register/ˈɪntərʌpt ˈredʒɪstə/ | 割り込みレジスタ |
| priority/praɪˈɒrɪti/ | The level of importance that decides which task or interrupt is handled first. |
キーボードを押した瞬間にラップトップがすべて停止してしまう理由
- プロセッサは秒単位で数十億回のサイクルを実行する。命令間にキーボードに「まだ何かあるか?」と問い合わせながら停止すれば、ほとんどの時間を尋ねるために浪費してしまう。
- 代わりにキーボードは割り込みを送信する。プロセッサは現在の命令を終了し、処理位置を保存し、キー入力を処理した後、何もしなかったかのように元の状態に戻る。
- この1つのメカニズムこそが、単一のプロセッサが音楽再生、ブラウザ操作、タイピングを同時に実行しているように見える理由である。
- この授業では、プロセッサが高速である理由、デバイスへの接続方法、命令の実行プロセス、割り込みの割り込み方式について解説する。
パフォーマンスに影響を与える要因
- クロック速度: 秒あたりのフォッチ-エグゼクートサイクル数が増えるため、秒あたりの命令実行数も増えるが、発熱が限界となる。
- コア数: 各コアが同時に独自の命令を取得・実行するため、複数のプログラムやスレッドが並列に動作する。プログラムがこれらのコアを活用するために書かれている必要があるため、コア数を倍にしても速度が必ずしも倍になるわけではない。
- Bus width: a wider data bus moves more bits per transfer, so fewer transfers; a wider address bus reaches more memory.
- キャッシュ: プロセッサの隣にある小型かつ高速なメモリで、最も最近使用された命令やデータを一時的に保持します。これにより、RAMへのアクセスという遅い移動を減らせます。ワードサイズ、RAM容量、ストレージの種類も性能に影響します。
CPU パフォーマンスに影響を与える要因をすべて選択してください。
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
クロック速度、コア、キャッシュ(およびワードサイズ、RAM、ストレージ、バス幅)はすべてパフォーマンスに影響します。ケースの色は影響しません。
マルチコア CPU は特に以下に役立ちます:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
余分なコアは並列にタスクを実行します。完全にスルースレッドの作業ほど、コアあたりの速度向上から恩恵を受けます。
____ メモリはプロセッサー隣接の小容量・高速記憶装置で、最近使用された指令とデータを保持し、RAM への低速アクセスを減らします。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
キャッシュが多いほど、ワークセットの大部分がプロセッサー隣接に置かれ、これがあらゆるパフォーマンス比較で登場する理由です。
解説例: 「新しいコンピューターが速い理由を説明せよ」
- 2つの仕様を行ごとに比較し、それぞれについて理由も示す。
- 3.8 GHz against 2.4 GHz: more cycles a second, so more instructions executed a second.
- 8 cores against 4: twice as many instructions can be fetched and executed at the same time, for software that uses them.
- 16 MB のキャッシュと 4 MB のキャッシュの比較: 動作中のデータセット( working set )のより大きな部分をプロセッサ近くに保持できるため、RAMへの待機時間が減る。各行は2点満点で評価され、要因と結果の両方を答える必要がある。

ポート
- ポートとは、周辺機器を接続するための物理的なソケットである。
- USB(ユニバーサルシリアルバス)は汎用的であり、キーボード、ドライブ、スマートフォンなどに使用される。プラグ&プレイ対応で、コンピュータがデバイスを検出し、識別し、ドライバーをロードし、給電也能行うため、再起動は不要である。
- HDMI(ハイデフィニション・マルチメディア・インターフェース)は、デジタル映像および音声信号を1本のケーブルで伝送するため、アナログへの変換がなく、画質の劣化がない。VGA(ビデオグラフィックス・アレイ)は、古いアナログ映像用のソケットである。
各ポートが伝送するものをそれぞれ対応させよ。
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
異なる信号には異なるソケットが必要である:HDMIケーブルはUSBポートには差し込めない。
フォッチ段階
- 命令ごとにプロセッサはフォッチ-エグゼキューティングサイクルを実行する。まずフォッチが行われ、試験ではこれをレジスタトランスファー表記法で記述することを求める。
MAR ← [PC] the address of the next instruction goes to the MAR
PC ← [PC] + 1 the PC now points to the following instruction
MDR ← [[MAR]] the instruction at that address is read into the MDR
CIR ← [MDR] the instruction is copied into the CIR for decoding
- リード信号はコントロールバス上を伝わり、アドレスはアドレスバス上を伝わり、指令値はデータバス上を戻ってくる。PCのアドレスがコピーされた直後にPCはインクリメントされるため、後で実行されるジャンプ命令によってPCの値が上書きされることがなくなる。

PC → MAR → メモリ → MDR → CIR、途中でのPCのインクリメントあり

フェッチ步骤を正しい順序に並べ替えよ。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
PC → MAR、PCのインクリメント、読込み信号、その後命令はMDR → CIRへ移動してデコード準備整う。
PCはフェッチ段階でインクリメントされるため、次のサイクルで次の命令を取得できる。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
PCを早期にインクリメントすることで、この命令が実行される時点ではすでに次の命令を指している(ジャンプによって変更されない限り)。
デコード、エグゼキュー、繰り返す
- デコード: コントロールユニットがCIR内の命令から、それがどの操作であり、演算子がどこにあるかを決定する。
- エグゼキュー: 算術論理演算はALUへ送られ、結果はACCに格納される。ロードまたはストアはメモリとレジスタ間のデータ転送を行う。ジャンプ命令は新しいアドレスをPCに書き込む。
- その後、サイクルは
MAR ← [PC]から繰り返される。各サイクルの終了時にも、プロセッサは割り込み待ちがあるかを確認する。
1回のLOADと1回のADDによるレジスタ操作: フォッチ、デコード、エグゼキュー、繰り返す
フェチ・エグゼキューションサイクル
CPu が秒間数十億回繰り返すループの周りをタップしてください。PC/MAR/MDR/CIR レジスタを使って how fetch が動作するか、そしてデコードとエグゼキューションがフェチされた内容进行如何处理看Watch how fetch uses the PC/MAR/MDR/CIR registers, then decode and execute act on what was fetched.
解説例: 表記法を用いた2命令の実行
LDD 200を実行する(アドレス200の内容をACCにロードする):MAR ← 200、次にMDR ← [[MAR]]、次にACC ← [MDR]。ADD 201を実行する:MAR ← 201、MDR ← [[MAR]]、ACC ← [ACC] + [MDR]。STO 202を実行する:MAR ← 202、MDR ← [ACC]、[[MAR]] ← [MDR]。- 各線は2つの間から1つの値を移動させる。二重括弧は常に「MARにあるアドレスを持つメモリアドレス」を意味する。
LDD 200を実行するレジスタ転送步骤を正しい順序に並べ替えよ。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
アドレスをMARへ、そのアドレスの contents をMDRへ、さらにアキュムレータへ移す。
割り込み
- 割り込みとは、通常のプロセスを一時停止させ、プロセッサが緊急イベントに対応できるようにする信号である。
- 原因: ハードウェアデバイス(キー押下、プリンタバッファ空、ネットワークパケット着信)、ソフトウェア障害(ゼロ除算、不正命令、算術オーバーフロー)、オペレーティングシステムのタイマーによるタイムスライスの終了、電源故障警告など。
- 割り込みにより、システムはプロセッサが常時デバイスをチェックする必要なく迅速に応答でき、これがオペレーティングシステムのマルチタスク機能の仕組みである。

各パスの終わりに割り込みチェックがあるサイクル

割り込みとは:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
割り込みはフェッチ・エグゼキューテCycleを一時停止させ、CPUが緊急イベントをサービスした後、再続する。
これらの中で割り込みを引き起こすものはどれか? すべて選択せよ。
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
ハードウェアイベント、ソフトウェア故障、OSタイマーはすべて割り込みを発生させる。ループの終了は通常のプログラムフローであり、ジャンプによって処理されるものであり、割り込みではない。
割り込み処理
- 現在の命令を完了させる。状態の保存: PCおよび他のレジスタの内容をスタックへ格納する。
- 割り込みサービスルーチン(ISR)のアドレスをPCへ読み込んで実行する。ISRがイベントを処理する。
- スタンクから保存された状態を復元し、中断されたプログラムが中断された地点からそのまま再開する。

保存、サービス、復元、再開

割り込みが発生すると、CPUはまず現在の命令を完了してから:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
PCとレジスタを保存し、割り込みサービスルーチンを実行してから状態を復元し、中断した地点から続ける。
解説例: 4点満点の割り込み問題への回答
- 入力デバイスからの割り込みがフォッチ-エグゼキューティングサイクル内でどのように検知され、処理されるかを説明せよ。
- デバイスは割り込み信号を送信し、割り込みレジスタ内のフラグを立てる。プロセッサは、現在の命令の実行が完了したサイクルの終端でそのレジスタを確認する。
- フラグが立てられており、割り込みの優先度が現在のタスクより高い場合、PCおよび他のレジスタはスタックへ保存される。ISRのアドレスがPCへ読み込まれ、ルーチンが実行される。
- 実行が完了すると、レジスタはスタックから復元され、中断されたプログラムがそのまま再開する。上記4点をこの順で答える。

プロセッサはフェッチ・エグゼキューテCycleの末尾、現在の命令が完了した後に割り込みの有無を確認する。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
このタイミングこそが、状態をきれいに保存できる理由である:命令が中途半端な状態で残ることはない。
見落としやすいポイント
- PCはエグゼキュー後ではなく、フォッチ中にインクリメントされる。
PC ← [PC] + 1を第2番目に配置し、MAR ← [PC]の直後に置く。 - 割り込みはサイクルの終端で確認され、命令の最中に確認されることはない。
- 状態はスタックへ送られ、そこから戻ってくる。「CPUが停止する」や「プログラムが失われる」という表現は誤りであり、元の位置から正確に再開することになる。
- コア数が増加しても速度が倍になるわけではありません。ソフトウェアがそれらを使用する必要があります。仕様を比較する際は、その点を明記してください。
理解できましたか
- パフォーマンス:クロック速度、コア数、バス幅、キャッシュ(およびワードサイズ、RAM、ストレージ)、それぞれに生じる影響
- ポート: USBは汎用かつプラグ&プレイ、HDMIはデジタル映像と音声、VGAはアナログ映像
- 取得:
MAR ← [PC],PC ← [PC] + 1,MDR ← [[MAR]],CIR ← [MDR]; その後、デコード、実行、繰り返す - 割り込みは各サイクルの終わりにチェックされる: ステートをスタックに保存し、ISRを実行し、復元して再続行する
何が問題でしたか?この内容はサイトの運営チームだけが確認します。