プリンキピア

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

TECHNOLOGY IN EVERYDAY LIFE日常生活の中の技術
Multitaskingマルチタスク
The ability to run multiple programs at once on computers today has a huge productivity impact in all industries. In concurrent programming, managing shared resources among multiple threads or processes is crucial for maintaining data integrity and preventing race conditions. One common scenario is the producer-consumer problem, where one or more threads (producers) generate data, and others (consumers) consume it. To avoid conflicts, synchronization mechanisms like locks and condition variables are employed. Locks help ensure that only one thread accesses a critical section of code at a time. In the context of the producer-consumer problem, locks can be utilized to safeguard shared data structures, preventing simultaneous access by multiple threads and ensuring data consistency.
英語のヒント
今日のコンピューターが複数のプログラムを一度に動かせることは、あらゆる産業の生産性に大きな影響を与えている。並行プログラミングでは、複数のスレッドやプロセスの間で共有リソースを管理することが、データの完全性を保ち、競合状態を防ぐために極めて重要である。よくある状況の一つが生産者・消費者問題であり、一つ以上のスレッドである生産者がデータを作り、ほかのスレッドである消費者がそれを消費する。競合を避けるために、ロックや条件変数などの同期の仕組みを使う。ロックは、一度に一つのスレッドだけがコードのクリティカルセクションへアクセスすることを確保する。生産者・消費者問題では、ロックによって共有データ構造を保護し、複数のスレッドによる同時アクセスを防ぎ、データの一貫性を保てる。
Condition variables are another synchronization tool that allows threads to coordinate their activities. In the context of producers and consumers, a condition variable could signal when data is available for consumption or when space is available for production. Threads can use these signals to efficiently wait for or notify others about the state of shared resources. The combination of locks and condition variables provides a powerful means to synchronize complex interactions between producers and consumers, ensuring orderly access to shared resources.
英語のヒント
条件変数は、スレッドが活動を調整できるようにする、もう一つの同期の道具である。生産者と消費者の場面では、消費できるデータがあるときや、生産に使える空き領域があるときに、条件変数で通知できる。スレッドは、この通知を使って、共有リソースの状態を効率よく待ったり、その状態をほかのスレッドへ知らせたりできる。ロックと条件変数の組み合わせは、生産者と消費者の複雑なやり取りを同期させ、共有リソースへの秩序あるアクセスを確保する、強力な手段となる。
Despite the benefits of synchronization mechanisms, the improper use of locks can lead to issues like deadlocks, where two or more threads or processes are stuck in a circular wait, unable to proceed because each is waiting for the other to release a resource. This situation can bring a system to a standstill, and careful design and coding practices are necessary to prevent or detect and recover from deadlocks. To handle deadlocks, techniques such as deadlock detection algorithms and prevention strategies are employed, contributing to the robustness of concurrent systems.
英語のヒント
同期の仕組みには利点があるものの、ロックを不適切に使うと、デッドロックなどの問題につながる。デッドロックでは、二つ以上のスレッドやプロセスが、互いに相手のリソース解放を待つため、循環した待ち状態から抜け出せず、先へ進めない。この状況はシステムを停止させかねない。デッドロックを防ぐ、または検出して回復するには、慎重な設計とコーディングが必要である。デッドロックに対処するため、検出アルゴリズムや予防戦略などの技法を使い、並行システムの頑健性を高める。
Allocation割り当て
The method that defines how data is stored in the memory by providing a set of requests for resources and identifying which processes should be given which resources to make the most efficient use of the resources is called allocation. Like scheduling, allocation is another kind of decision-making that an OS performs about how to use resources to support concurrency. There are three main forms of allocation: contiguous allocation, linked allocation, and indexed allocation.
英語のヒント
リソースへの要求の集合を与え、リソースを最も効率よく使うために、どのプロセスへどのリソースを与えるかを識別し、メモリ内でデータをどのように格納するかを定める方法を、割り当てという。スケジューリングと同様に、割り当ても、並行性を支えるためのリソースの使い方についてOSが行う意思決定の一種である。割り当てには、連続割り当て、連結割り当て、索引割り当てという三つの主な形式がある。
In contiguous allocation, each file is assigned to a contiguous (i.e., neighboring) set of blocks in the memory. For example, if a file requires three blocks and is given a starting location x, the file will be allocated in x, x + 1, x + 2. The directory entry with contiguous allocation contains the starting block address and the length of the file. In linked allocation, each file is a linked list of memory blocks. Using the same example, the first block will be allocated in location x and it will include the address of the second block. The directory entry with linked allocation contains a pointer to the starting block and a pointer to the last block. In indexed allocation, each file has an index block containing the pointers to all blocks for that file.
英語のヒント
連続割り当てでは、各ファイルに、メモリ内で連続した、つまり隣り合うブロックの集合を割り当てる。たとえば、ファイルに3ブロック必要で、開始位置をxとすると、x、x + 1、x + 2に割り当てる。連続割り当てのディレクトリー項目には、開始ブロックのアドレスと、ファイルの長さが入る。連結割り当てでは、各ファイルはメモリブロックの連結リストである。同じ例なら、最初のブロックを位置xに割り当て、その中に2番目のブロックのアドレスを入れる。連結割り当てのディレクトリー項目には、開始ブロックへのポインターと、最後のブロックへのポインターが入る。索引割り当てでは、各ファイルに索引ブロックがあり、そのファイルのすべてのブロックへのポインターを格納する。