Virtual memory, paging and segmentation
導入済み
13:59
リソース、コンパイラ & RPN
ブラウザ、音楽プレイヤー、ゲームを開きます。プロセッサは1つ(コアが数個あるかもしれません)ですが、すべてが同時に動いているように見えます。そしてこれらはすべて…もっと必要なことを求めています。
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| disk/dɪsk/ | A storage device that holds programs and data even when power is off. |
| applications/ˌæplɪˈkeɪʃnz/ | Programs designed to help users carry out particular tasks. |
| memory/ˈmeməri/ | The part of a computer that holds data and programs currently in use. |
| processor/ˈprəʊsesə/ | The component that executes instructions and performs the operations of a computer or similar system. |
| pages/ˈpeɪdʒɪz/ | ページ |
| virtual memory/ˈvɜːtʃuːəl ˈmeməri/ | A memory-management system that maps virtual addresses to physical storage and may move pages between RAM and secondary storage. |
| paging/ˈpeɪdʒɪŋ/ | ページング |
| segmentation/ˌseɡmənˈteɪʃn/ | セグメンテーション |
| virtual address space/ˈvɜːtʃuːəl əˈdres speɪs/ | 仮想アドレス空間 |
| process/ˈprəʊses/ | An instance of a program in execution together with its execution state and allocated resources. |
| addresses | Numbers that identify specific locations in a computer's memory. |
| OS | The software that manages a computer's hardware, memory and running programs. |
| physical RAM | The actual memory hardware that holds data and instructions currently in use. |
| physical memory | The actual memory hardware that holds data and programs currently in use. |
| frames/freɪmz/ | フレーム |
| page table/peɪdʒ ˈteɪbl/ | ページテーブル |
| hardware/ˈhɑːdweə/ | The physical parts of a computer system that can be touched. |
| page fault/peɪdʒ fɒlt/ | ページフォルト |
| swap file/swɒp faɪl/ | スワップファイル |
| interrupt/ˈɪntərʌpt/ | A signal or event that causes the processor to suspend normal execution and run an appropriate service routine. |
| blocked/blɒkt/ | A process state in which execution waits for an event or resource, such as I/O completion, rather than merely waiting for the CPU. |
| ready state | The state of a process that can run when the processor becomes available. |
| instruction/ɪnˈstrʌkʃn/ | A command that tells the processor what action to perform. |
| thrashing/ˈθræʃɪŋ/ | スラッシング |
| working set | The instructions and data a program is currently using or likely to need. |
| swapping | The movement of pages between physical memory and disk as they are needed. |
| disk thrashing/dɪsk ˈθræʃɪŋ/ | A state where the system spends more time moving pages than executing instructions. |
| logical segments | Parts of a program's memory that represent meaningful units and can differ in size. |
| code/kəʊd/ | Instructions written in a programming language for a computer to follow. |
| stack/stæk/ | A last-in, first-out data structure in which items are added and removed at the same end. |
| heap/hiːp/ | An area of memory used for data created while a program runs. |
| permissions | Rules that decide what a user can access or change. |
| code segment/kəʊd ˈseɡmənt/ | The part of a program's memory that holds its executable instructions. |
| access permissions | Rules that control whether a process can read, write or execute a memory segment. |
機械が諦めたことを示すディスクライト
- メモリが不足しているマシンで開きすぎると、特徴的な現象が起こる。すべての処理がほぼ停止状態に近くなり、ディスクのライトが点滅をやめて常時点灯する。
- プロセッサは忙しくない。メモリを待っているのだ。各プログラムに必要なメモリがディスクにあるため、1ページの読み出しを行うと、少し後に必要な別のページが追放されてしまうからである。
- マシンは何もしていない。ページ移動のみを行っている。 neither 作業量もメモリ量も、どちらか一方を適切に処理できるレベルではない。
- このレッスンの主題は仮想メモリであり、ページングとセグメンテーションがどうしてこれを可能にするか、また同じ仕組みがメモリを大きく見せる一方でマシンを機能不全に陥らせるのかについて学ぶ。
仮想アドレス空間
- 各プロセスには独自の仮想アドレス空間が割り当てられる。これはゼロから始まる、OSによって実際のデータの位置にマッピングされる、クリーンで連続したアドレス範囲である。
- これにより3つのことが実現される。各プロセスは単純なプライベート空間だけを見ることができ、他の何-runningされているかを知らなくてもよい。プロセス同士は保護されており、他プロセスの空間内のアドレスを指定することはできない。さらに、使用総量は物理RAMを超えることができ、その一部はディスク上に存在するためである。
- この隔離は利便性だけでなく、セキュリティ境界としても機能する。

A benefit of virtual memory is that it:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Virtual memory gives each process a private space and lets the working set exceed installed RAM by using disk.
What does giving each process a virtual address space achieve? Select すべて that apply.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Virtual memory buys simplicity, isolation and capacity. It costs speed, since part of the memory is really on disk.
ページング
- 仮想空間は固定サイズのページに分割され、物理メモリは同じサイズのフレームに分割される。ページテーブルは、どのフレームに現在どのページが格納されているかを記録している。
- プロセスがアドレスを使用すると、ハードウェアはテーブル内でページを検索し、対応するフレームを見つける。もしページがRAMにない場合、それはページフォールトである。
- ページフォールトが発生すると、OSはディスク上のスワップファイルからページを読み出して自由なフレームにロードする。もし自由なフレームがない場合、まず追放すべきページを選択し、変更があればディスクへ書き戻す必要がある。

同じサイズのページとフレーム、テーブルによって接続

In paging, memory is divided into:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Paging uses fixed-size pages and frames, linked by a page table. (Variable sizes are segmentation.)
A page fault occurs when:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
The accessed page isn't in a frame, so the OS fetches it from the swap file (evicting another page if needed).
演習例:ページフォールト時の動作
- RAMにないページを持つアドレスにアクセスした場合、OSが行うことを説明せよ。 [4]
- ハードウェアはページが存在しないことを検知し、ページフォールト割り込みを発生させ、プロセスはブロックされる。
- OSは自由なフレームを探す。もしない場合、置き換え対象のページを選定し、変更があればスワップファイルへ書き戻す。
- 必要なページをスワップファイルからそのフレームへ読み込み、ページテーブルを更新する。
- プロセスは準備完了状態に戻され、命令が再試行される。4つのステップ、4ポイント。なおプロセスはブロックされたままだったことに注意せよ。
What happens on a page fault
Step through a page fault. When the program touches a page that isn't in RAM, the OS quietly fetches it from disk and updates the page table — so the program sees more memory than physically exists.
Put the OS's response to a page fault in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Detect and block, make room, load, record, retry. A page fault is the normal mechanism, not an error.
スラッシング
- どのページを置き換えるかを選ぶことは重要である。誤った選択をすると、すぐにそのページが必要となり再度追放されることになるからである。
- 実行中のプロセスのワーキングセットに対してRAMが不足すると、ほとんどのアクセスがページフォールトを引き起こし、各フォールトが追放したページが直ちに必要となる状態になる。
- システムはthen nearly all its time 命令を実行する代わりにページをスワップすることに費やす。これがスラッシング(またはディスクスラッシング)であり、このレッスンの冒頭で記述された状態である。
- 解決策はRAMを増やすか、プロセス数を減らすことである。プロセッサを速くしても全く役に立たない。なぜなら、忙しくなっているのはプロセッサだからではないからである。
A machine slows almost to a stop and the disk runs constantly. What will fix it?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
This is thrashing: nearly every access faults and the processor waits. The processor is not the busy component, so speeding it up changes nothing.
セグメンテーション
- セグメンテーションは、プログラムの構造(コード、スタック、ヒープ、大規模データ配列など)に対応する可変サイズの論理セグメントにメモリを分割する。
- セグメントは論理的単位であるため、独自の権限を持つことができる。コードセグメントは読み取り専用かつ実行可能、スタックは読み書き可能かつ非実行可能とするなどである。
- 試験が求める対比:.ページは固定サイズでプログラムにとって意味を持たず、セグメントは可変サイズでプログラムの論理的部分に対応する。多くの実システムでは両者を組み合わせており、セグメント内でページングを行う。

セグメントはプログラムの固有の構成要素であり、均等なスライスではない

Match each memory-management term to its meaning.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Paging = fixed pages; segmentation = logical variable units; a page fault triggers a swap; too many faults = thrashing.
Segmentation divides memory into variable-sized logical units (code, stack, heap), each with its own permissions, whereas paging uses fixed-size pages.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Segments match the program's logical structure; pages are uniform fixed-size blocks — some systems combine both.
Unlike pages, which are all the same size, segments are of ____ size and match the program's logical parts.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A segment is the code, the stack or the heap, so it can carry its own permissions. A page is a fixed-size division of virtual memory with no inherent meaning to the program.
演習例:ページングとセグメンテーションの比較
- ページングとセグメンテーションの違いを2つ述べよ。 [2]
- ページはすべて固定サイズで、システム側で決定される。セグメントは可変サイズで、プログラムの論理的構成部によって決定される。
- ページはプログラムにとって意味のない純粋な物理的な区切りであるのに対し、セグメントはコードやスタックなどの論理的単位に対応しており、独自のアクセス権限を与えることができる。
- 必要であれば第3の理由として:ページングは割当先最終ページの内部に未使用スペースを残すことがあるが、セグメンテーションはセグメント間の隙間に利用不能なスペースを残す。

見落としやすいポイント
- 仮想メモリはメモリを生成するものではない。一部のデータをディスク上に保持することで、使用総量を物理RAMを超えることを可能にし、その代償としてディスクアクセスが発生する。
- ページフォールトはエラーではない。ページを読み込むための通常のメカニズムである。
- スラッシングとは実行よりスワップに時間を割くことであり、対策はRAM増強またはプロセス削減であり、プロセッサの高速化は決して有効ではない。
- 固定サイズ versus 可変サイズ・論理的意味ありがページングとセグメンテーションの違いである。両方の側面を述べること。
理解できましたか
- 仮想アドレス空間は各プロセスにプライベートで連続した範囲を与え、プロセス同士を保護し、使用量を物理RAMを超えることを許容する。
- ページング:固定サイズのページがページテーブルによってフレームにマッピングされる。ページフォールトによりプロセスがブロックされ、OSは必要に応じてページを追放し、スワップファイルから読み込み、テーブルを更新して再試行する。
- スラッシングは実行よりスワップに時間を割くことであり、対策はRAM増強またはプロセス削減である。
- セグメンテーションは、プログラムの論理的部分に一致する可変サイズのセグメントを使用し、それぞれが独自の権限を持ちます。多くのシステムではセグメント内でページングを行います。
何が問題でしたか?この内容はサイトの運営チームだけが確認します。