プリンキピア

第6章インフラストラクチャーの抽象化層:オペレーティングシステム

OS StructureOSの構造

In this section, we learn about the organization and structure of the OS. As you may recall, an OS consists of many core components but also includes other components such as privileged and non-privileged system programs. In an OS, it is important to have dual mode operations to ensure a high level of security and authority. The dual mode is responsible for separating the user mode from the kernel mode. A program that can run only in the kernel mode is known as a privileged system program. An example of a privileged system program is the bootstrap code, which is the first code that is executed when the OS starts. The OS depends on the bootstrap to be loaded and to work correctly. Figure 6.10 demonstrates the bootstrap use. If the user attempts to make any execution on privileged systems instructions, the execution will not be performed.
英語のヒント
この節では、OSの構成と構造を学ぶ。OSは、多くの中核的な構成要素のほかに、特権システムプログラムや非特権システムプログラムなども含むことを思い出そう。高いセキュリティーと権限を確保するため、OSでは二つのモードで動作することが重要である。このデュアルモードによって、ユーザーモードとカーネルモードを分離する。カーネルモードでしか動作できないプログラムを、特権システムプログラムという。一例は、OSの開始時に最初に実行されるブートストラップコードである。OSが読み込まれ、正しく動くには、ブートストラップに依存する。図6.10は、その使い方を示す。利用者が特権システム命令を実行しようとしても、実行されない。
Figure 6.10

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 6.10 To start using any device, the OS will use the bootstrap program. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図6.10 機器を使い始めるため、OSはブートストラッププログラムを使う。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
A program that can run only in the user mode is called a non-privileged system program. An example of a non-privileged system program is reading the processor status and the system time. In general, this is an instruction that any application or user can execute.
英語のヒント
ユーザーモードでしか動作できないプログラムを、非特権システムプログラムという。例には、プロセッサの状態やシステム時刻の読み取りがある。一般に、これはどのアプリケーションや利用者でも実行できる命令である。
Designing a large, complex program is a major software engineering challenge because the program must not only perform well, but it must also be reliable, extensible, and backward compatible. OS design has been an evolutionary trial and error process. Successful OS designs have had a variety of architectures, such as monolithic, layered, cloud infrastructure and exokernels, microkernels, and virtual machine monitors. As the design of an OS—and even its role—are still evolving, it is simply impossible today to pick one correct way to structure an OS. The choice of OS architecture depends on various factors, including the specific requirements, trade-offs, and goals of the OS’s intended use.
英語のヒント
大規模で複雑なプログラムの設計は、ソフトウェア工学の大きな課題である。性能がよいだけでなく、信頼性、拡張性、後方互換性も求められるからだ。OSの設計は、試行錯誤を通じて進化してきた。成功した設計には、モノリシック、階層型、クラウド基盤とエクソカーネル、マイクロカーネル、仮想マシンモニターなど、さまざまなアーキテクチャーがある。OSの設計は、役割そのものも含めて今なお進化しているため、今日、構造の唯一正しい方法を選ぶことはできない。アーキテクチャーの選択は、具体的な要件、トレードオフ、想定する用途の目標など、多くの要因によって決まる。
Monolithic OS DesignモノリシックOS設計
A monolithic design refers to a specific architecture for OSs where the entire OS operates within the kernel space, and all components and functionalities of the operating system are organized within the space. In a monolithic architecture, the entire operating system functions as a single, integrated unit, and all of its components, such as process management, file systems, device drivers, and memory management, reside and operate within the same address space, known as the kernel space. This means that the entire OS operates as a single, large program, and any module or component can directly call the functions of another without any restrictions.
英語のヒント
モノリシック設計は、OS全体がカーネル空間で動作し、すべての構成要素と機能をその空間内にまとめる、特定のOSアーキテクチャーである。OS全体が単一の統合された単位として機能し、プロセス管理、ファイルシステム、デバイスドライバー、メモリ管理など、すべての構成要素が、カーネル空間という同じアドレス空間内に存在し、動作する。つまり、OS全体が一つの大きなプログラムとして動き、どのモジュールや構成要素も、制限なくほかの機能を直接呼び出せる。
While a monolithic design simplifies the communication and interaction between OS components, it has both advantages and disadvantages. One advantage is that it generally provides efficient and fast communication between different parts of the OS because they share the same address space. Another major advantage of the monolithic design is that it uses a familiar architectural style, and the cost of module interactions in terms of procedure calls is low. However, there are many disadvantages. Namely, this structure is hard to understand, modify, or maintain, and does not support fault containment. A failure in any one component can potentially crash the entire system, making it less fault-tolerant compared to more modular architectures. In this case, the alternative is to find an organizational way to simplify the OS design and implementation.
英語のヒント
モノリシック設計は、OSの構成要素間の通信とやり取りを単純にするが、長所と短所の両方を持つ。長所の一つは、同じアドレス空間を共有するため、OSの異なる部分の間で、一般に効率的で高速な通信ができることだ。もう一つの大きな長所は、なじみのあるアーキテクチャーの形式を使い、モジュール間の手続き呼び出しのコストが低いことである。しかし、短所も多い。この構造は、理解、変更、保守が難しく、障害の封じ込めに対応しない。どれか一つの構成要素の障害が、システム全体を停止させる可能性があり、よりモジュール化されたアーキテクチャーより耐障害性が低い。この場合の代案は、OSの設計と実装を単純にする構成方法を探すことである。
Traditional OSs such as UNIX (Figure 6.11) were built using the monolithic architecture. In contrast to monolithic designs, other OS architectures such as microkernel or hybrid designs distribute OS functionalities into separate modules or user-space processes, leading to better modularity and potentially improved system stability.
英語のヒント
UNIXのような従来のOS(図6.11)は、モノリシックアーキテクチャーで作られていた。それに対して、マイクロカーネルやハイブリッド設計などのほかのアーキテクチャーは、OSの機能を別々のモジュールやユーザー空間のプロセスへ分散させる。これにより、モジュール性が高まり、システムの安定性も向上する可能性がある。
Figure 6.11

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 6.11 The entire OS works as one piece in the monolithic architecture. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図6.11 モノリシックアーキテクチャーでは、OS全体が一つのまとまりとして動作する。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
Layered OS Design階層型OS設計
One alternative way to achieve monolithic OS design is the layered OS architecture, which consists of implementing the OS as a set of layers where each layer exposes an enhanced “virtual machine” to the layer above, as illustrated in Figure 6.12.
英語のヒント
モノリシックOS設計を実現する別の方法の一つが、階層型OSアーキテクチャーである。図6.12のように、OSを複数の層として実装し、各層が上位の層に、機能を強化した「仮想マシン」を提供する。
Figure 6.12

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 6.12 In a layered OS architecture, the OS is divided into layers, and each layer will be responsible for a specific task. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図6.12 階層型OSアーキテクチャーでは、OSを層に分け、各層が特定の仕事を担当する。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
The first example of a layered approach was Dijkstra’s THE system, which was designed in 1968. There were six layers, and they were organized as follows.
階層方式の最初の例は、1968年に設計されたダイクストラのTHEシステムである。六つの層があり、次のように構成されていた。
• Layer 5: A job manager executes users’ programs.
• 第5層:ジョブマネージャーが、利用者のプログラムを実行する。
• Layer 4: A device manager handles devices and provides buffering.
• 第4層:デバイスマネージャーが機器を扱い、バッファリングを提供する。
• Layer 3: A console manager implements virtual consoles.
• 第3層:コンソールマネージャーが、仮想コンソールを実装する。
• Layer 2: A page manager implements virtual memories for each process.
• 第2層:ページマネージャーが、各プロセスの仮想記憶を実装する。
• Layer 1: A kernel implements a virtual processor for each process.
• 第1層:カーネルが、各プロセスの仮想プロセッサを実装する。
• Layer 0: Hardware is the physical components of the computer.
• 第0層:ハードウェア、すなわちコンピューターの物理的な構成要素。
Each layer in this setup can be tested and verified independently. Layering also helped with implementation and supported attempts at formal verification of correctness (if you can call only layers below, it is not possible to run into a loop across the various layers).
英語のヒント
この構成では、各層を独立してテストし、検証できる。階層化は実装にも役立ち、正しさの形式的検証の試みを支えた。下位の層だけを呼び出せるなら、さまざまな層をまたぐループに陥ることはないからである。
There are, however, many disadvantages to using the layered OS architecture. Namely, it imposes a hierarchical structure, while real systems are more complex because a file system requires virtual memory (VM) services, and the VM likes to use files for its backing store. Layering also imposes a performance penalty as each layer crossing has overhead associated with static versus dynamic enforcement of invocation restrictions. There is also a disconnect between model and reality as systems modeled as layers may not really be built that way.
英語のヒント
しかし、階層型OSにも多くの短所がある。この方式は階層構造を強制するが、実際のシステムはもっと複雑である。ファイルシステムは仮想記憶(VM)のサービスを必要とし、VMも退避用の記憶領域にファイルを使いたいからだ。また、層を越えるたびに、呼び出し制限を静的または動的に強制することに伴うオーバーヘッドが生じるため、階層化には性能上の負担がある。さらに、モデルでは階層になっていても、実際にはその形で構築されていないことがあり、モデルと現実の隔たりも生じる。