markdown
計算機システムの基本md b8b634f
lecture/information/systems/computer-systems-basics.lecture.n.md
Download PDF

計算機けいさんきシステムの基本きほん

date2026-07-14document_iddoc_081f8ffb84ffda562468ed65e53d2fdfdescription計算機システムをCPU・メモリ・入出力の協調として捉え、命令サイクル、記憶階層、性能評価の基本を説明する。prerequisitesプログラミングの基本 / 二進表現と論理演算の初歩type講義statusactiverelateddata/lecture/information/systems/computer-systems-portal.lecture.n.md / data/lecture/information/programming/introduction-to-programming.lecture.n.md / data/lecture/information/algorithm/foundation/computational-complexity-basics.lecture.n.md / data/lecture/information/networks/computer-networks-portal.lecture.n.md
informationsystemsundergraduatelecture
data/lecture/information/systems/computer-systems-portal.lecture.n.md

1導入どうにゅう

この講義こうぎでは、CPUCentral Processing Unit、主記憶しゅきおくMain memory、入出力にゅうしゅつりょくInputoutput; IOが協調きょうちょうしてプログラムを実行じっこうする過程かていを説明せつめいする。命令めいれいの実行じっこう、データの保持ほじ、外部装置がいぶそうちとのデータ交換こうかんを区別くべつすることにより、プログラムの振ふる舞まいと計算機けいさんきの構成こうせいを対応たいおうづける。

2格納かくのうプログラム方式ほうしき

格納かくのうプログラム方式ほうしきStored-program architectureでは、プログラムを構成こうせいする命令めいれいと、その命令めいれいが処理しょりするデータを、いずれも主記憶しゅきおくに配置はいちする。CPUは主記憶しゅきおくから次つぎに実行じっこうする命令めいれいを取得しゅとくし、その命令めいれいが指定していする演算えんざんを実行じっこうする。

主記憶しゅきおくは番地ばんちAddressによって識別しきべつされる記憶場所きおくばしょの集合しゅうごうとして扱あつかえる。プログラムの変数へんすうは、実行時じっこうじには値あたいを格納かくのうする記憶場所きおくばしょまたはその場所ばしょを参照さんしょうする仕組しくみに対応たいおうする。ただし、コンパイラによる最適化さいてきかでは、値あたいがCPU内部ないぶのレジスタだけに保持ほじされることもあるため、すべての変数へんすうが常つねに主記憶しゅきおくの固定番地こていばんちを占有せんゆうするわけではない。

3CPUと命令めいれいサイクル

CPUは、演算えんざんを実行じっこうする演算装置えんざんそうちArithmetic and logic unit; ALU、命令実行めいれいじっこうを制御せいぎょする制御装置せいぎょそうちControl unit、少量しょうりょうのデータを高速こうそくに保持ほじするレジスタRegisterなどから構成こうせいされる。

命令めいれいの処理しょりは、概念的がいねんてきには次つぎの命令めいれいサイクルInstruction cycleとして整理せいりできる。

  1. 取とり出だしFetch: 次つぎに実行じっこうする命令めいれいを主記憶しゅきおくから取得しゅとくする。
  2. 解読かいどくDecode: 命令めいれいが要求ようきゅうする演算えんざんと対象たいしょうを判定はんていする。
  3. 実行じっこうExecute: 演算えんざん、データ転送てんそう、または分岐ぶんきを実行じっこうする。
  4. 書かき戻もどしWrite-back: 必要ひつように応おうじて結果けっかをレジスタまたは主記憶しゅきおくへ保存ほぞんする。

たとえば、二ふたつの値あたいをレジスタへ読よみ込こんだ後あとに加算かさんする処理しょりでは、加算命令かさんめいれいがALUに演算えんざんを指示しじし、結果けっかをレジスタへ保存ほぞんする。どの命令めいれいがメモリを直接ちょくせつ参照さんしょうできるかは、命令めいれいセットによって異ことなる。条件分岐じょうけんぶんきは、条件じょうけんに応おうじて次つぎに取得しゅとくする命令めいれいの番地ばんちを変更へんこうする。

4記憶階層きおくかいそう

記憶装置きおくそうちの容量ようりょう、速度そくど、単位容量たんいようりょうあたりの費用ひようの間あいだにはトレードオフがある。このため、計算機けいさんきは一般いっぱんに、レジスタ、キャッシュ、主記憶しゅきおく、補助記憶ほじょきおくという記憶階層きおくかいそうMemory hierarchyを構成こうせいする。

レジスタ⟶キャッシュ⟶主記憶⟶補助記憶

左側ひだりがわほどCPUに近ちかく、高速こうそくかつ小容量しょうようりょうである。プログラムによるメモリ参照さんしょうには、短みじかい時間じかんに同一どういつの記憶場所きおくばしょまたはその近傍きんぼうへ参照さんしょうが集中しゅうちゅうする傾向けいこうがある。この傾向けいこうを参照さんしょうの局所性きょくしょせいLocality of referenceという。記憶階層きおくかいそうは、この局所性きょくしょせいを利用りようして、頻繁ひんぱんに参照さんしょうするデータをCPUに近ちかい階層かいそうで再利用さいりようする。

5入出力にゅうしゅつりょく

入出力にゅうしゅつりょくは、ディスプレイ、キーボード、補助記憶装置ほじょきおくそうち、ネットワークインタフェースなどとデータを交換こうかんする機能きのうである。CPUと入出力装置にゅうしゅつりょくそうちには動作速度どうさそくどの差さがあるため、CPUが完了かんりょうを待機たいきし続つづける方式ほうしきだけではCPU時間じかんを有効ゆうこうに利用りようできない。割込わりこみは装置そうちの状態変化じょうたいへんかや処理完了しょりかんりょうをCPUへ通知つうちする。DMADirect Memory Accessは、CPUがデータを一語いちごずつ転送てんそうすることなく、装置そうちと主記憶しゅきおくの間あいだでデータを転送てんそうする。これらは、CPUと入出力にゅうしゅつりょくの並行動作へいこうどうさを支援しえんする代表的だいひょうてきな仕組しくみである。

ネットワーク通信つうしんも入出力にゅうしゅつりょくの一種いっしゅである。後続こうぞくのネットワーク講義こうぎでは、データを複数ふくすうの計算機けいさんきの間あいだで転送てんそうする仕組しくみを詳述しょうじゅつする。

6性能せいのうを区別くべつして評価ひょうかする

プログラムの所要時間しょようじかんを分析ぶんせきするときは、少すくなくとも次つぎの要因よういんを区別くべつする。

  • CPUが命令めいれいを実行じっこうする時間じかん
  • 記憶階層きおくかいそうからデータを取得しゅとくする時間じかん
  • 入出力にゅうしゅつりょくの完了かんりょうを待まつ時間じかん

アルゴリズムの計算量けいさんりょうは、入力規模にゅうりょくきぼに対たいして必要ひつような演算回数えんざんかいすうや記憶量きおくりょうがどのように増加ぞうかするかを抽象的ちゅうしょうてきに表あらわす。実測時間じっそくじかんは、それに加くわえてCPU、記憶階層きおくかいそう、入出力装置にゅうしゅつりょくそうち、実装じっそうなどの影響えいきょうを受うける。したがって、計算量けいさんりょうと特定とくていの計算機けいさんきにおける実測時間じっそくじかんは同一どういつではない。

7要点ようてん

  • 格納かくのうプログラム方式ほうしきでは、命令めいれいとデータを主記憶しゅきおくに配置はいちし、CPUが命令めいれいサイクルに従したがって処理しょりする。
  • 記憶階層きおくかいそうは、速度そくど、容量ようりょう、費用ひようの相違そういを利用りようしてデータ参照さんしょうを効率化こうりつかする。
  • 実行時間じっこうじかんの分析ぶんせきでは、CPU処理しょり、メモリ参照さんしょう、入出力待機にゅうしゅつりょくたいきを区別くべつする。

8次つぎに進すすむ講義こうぎ

data/lecture/information/networks/computer-networks-portal.lecture.n.md

Computer Systems Fundamentals

data/lecture/information/systems/computer-systems-portal.lecture.n.md

1Introduction

This lecture explains how the CPUCentral Processing Unit, main memoryMain memory, and inputoutputInputoutput; IO cooperate to execute a program. By distinguishing instruction execution, data storage, and exchange with external devices, it connects program behavior to computer organization.

2Stored-Program Architecture

In a stored-program architectureStored-program architecture, both the instructions that constitute a program and the data processed by those instructions reside in main memory. The CPU retrieves instructions from main memory and performs the operations that they specify.

Main memory can be treated as a collection of storage locations identified by addressesAddress. At run time, a program variable corresponds to a location that stores a value or to a mechanism for referring to that location. Compiler optimizations may keep a value solely in a CPU register, so not every variable permanently occupies a fixed address in main memory.

3The CPU and the Instruction Cycle

A CPU includes an arithmetic and logic unitArithmetic and logic unit; ALU that performs operations, a control unitControl unit that directs instruction execution, and registersRegister that provide a small amount of high-speed storage.

Instruction processing can be organized conceptually as the following instruction cycleInstruction cycle.

  1. FetchFetch: Retrieve the next instruction from main memory.
  2. DecodeDecode: Determine the operation and operands specified by the instruction.
  3. ExecuteExecute: Perform an operation, data transfer, or branch.
  4. Write-backWrite-back: Store the result in a register or main memory when required.

For example, in a computation that loads two values into registers and then adds them, an addition instruction directs the ALU to perform the operation and stores the result in a register. Whether an instruction can refer to memory directly depends on the instruction set. A conditional branch changes the address of the next instruction according to a condition.

4Memory Hierarchy

Storage technologies involve tradeoffs among capacity, speed, and cost per unit of capacity. Computers therefore generally organize storage as a memory hierarchyMemory hierarchy consisting of registers, caches, main memory, and secondary storage.

registers⟶caches⟶mainmemory⟶secondarystorage

Components farther to the left are closer to the CPU, faster, and smaller. A program tends to concentrate its memory references on the same storage locations or nearby locations over a short period. This tendency is called locality of referenceLocality of reference. A memory hierarchy exploits locality by reusing frequently accessed data at levels close to the CPU.

5Input/Output

Input/output exchanges data with displays, keyboards, secondary storage devices, network interfaces, and other devices. Because CPUs and I/O devices operate at different speeds, a design in which the CPU merely waits for each operation to finish cannot use CPU time efficiently. An interrupt notifies the CPU of a device state change or operation completion. DMADirect Memory Access transfers data between a device and main memory without requiring the CPU to move each word. These mechanisms help CPU execution and input/output proceed concurrently.

Network communication is also a form of input/output. The following network lectures explain how data is transferred among multiple computers.

6Distinguishing Sources of Performance

An analysis of program execution time should distinguish at least the following factors:

  • time spent executing instructions on the CPU;
  • time spent obtaining data from the memory hierarchy; and
  • time spent waiting for input/output to complete.

Algorithmic complexity abstracts how the required number of operations or amount of storage grows with input size. Measured execution time additionally depends on the CPU, memory hierarchy, I/O devices, implementation, and other factors. Algorithmic complexity and measured time on a particular computer are therefore not identical.

7Key Points

  • In a stored-program architecture, instructions and data reside in main memory, and the CPU processes instructions through an instruction cycle.
  • A memory hierarchy exploits differences in speed, capacity, and cost to make data access efficient.
  • Performance analysis distinguishes CPU processing, memory access, and input/output waiting time.

8Next Lecture

data/lecture/information/networks/computer-networks-portal.lecture.n.md
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる