Operating System Concepts 8章練習問題

恐竜本8章練習問題です。結構忘れていて残念でした。

8.1 Name two differences between logical and physical addresses.
自身の回答:Logicalはプログラムが認識するアドレス空間で、0から連続的に連なっている。Physicalはコンピュータのメモリに物理的に存在するアドレス空間。LogicalとPhysicalはページテーブルでつながっており、Logicalに対応するPhysicalアドレスは一般的にページ単位で飛び飛びになる。
解答:論理アドレスは実際のアドレスを意味せず、抽象的なアドレス空間を意味する。物理アドレスはその逆である。論理アドレスはCPUによって生成され、メモリマネジメントユニット(MMU)によって物理アドレスに変換される。

8.2

Consider a system in which a program can be separated into two
parts: code and data. The CPU knows whether it wants an instruction (instruction fetch) or data (data fetch or store). Therefore, two base–limit register pairs are provided: one for instructions and one for data. The instruction base–limit register pair is automatically read-only, so programs can be shared among different users. Discuss the advantages and disadvantages of this scheme.
回答:
利点:
欠点:レジスタの個数が増え、コストが増える
解答:利点はコードとデータの共有に効果的なメカニズムであるということである。例えばエディターもしくはコンパイラのコードのコピーを1個だけメモリ上に保持すれば良く、それらにアクセスする必要があるすべてのプロセスによって共有することができる。また、間違ってコードを変更することから保護することができる。欠点はコードとデータの分離をしなければならないということであるが、コンパイラがそういうコードを生成してくれる。

8.3 Why are page sizes always powers of 2?
回答:TLBの物理的制約
解答:ページ番号とオフセットを論理アドレスから計算するときに、論理アドレスの上nビットがページ番号、下mビットがオフセットになっていると、ビットシフトで計算でき、簡易になるため。

8.4 Consider a logical address space of 64 pages of 1024 words each, mapped onto a physical memory of 32 frames.
a. How many bits are there in the logical address?
b. How many bits are there in the physical address?
回答:a. 16102464=2^20
b. 同上
解答:a 16bit b 15bit1

8.5 What is the effect of allowing two entries in a page table to point to the same page frame in memory? Explain how this effect could be used to decrease the amount of time needed to copy a large amount of memory from one place to another. What effect would updating some byte on the one page have on the other page?

回答:ある論理アドレスへの書き込みが別の論理アドレスへと遅延0で波及する。関数やプログラム間のデータの受け渡しが高速になる。
解答:コードとデータをユーザーが共有できる。コードが再入可能であれば大きなプログラムの共有で多くのメモリを節約できる。大きなサイズのデータのコピーはページテーブルのエントリーを同じアドレス領域を指すようするだけで済む。しかし、歳入不可能なコードやデータを共有すると、コードにアクセスできるユーザーは誰でもそれを変更できることを意味し、他のユーザーの「コピー」に影響を与えてしまう。

8.6

Describe a mechanism by which one segment could belong to the address space of two different processes.
回答:
解答:セグメントテーブルはbase-limitレジスタの集合であり、セグメントは別のジョブのセグメントテーブルでエントリーが同じ物理的位置を指すようにすることで共有できる。2つのセグメントテーブルは同じbaseポインタを保持し、共有されるセグメント数は2つのプロセスで同じ担っていなければならない。

8.7 Sharing segments among processes without requiring that they have the same segment number is possible in a dynamically linked segmentation system.
a. Define a system that allows static linking and sharing of segments without requiring that the segment numbers be the same.
b. Describe a paging scheme that allows pages to be shared without
requiring that the page numbers be the same.
回答:a
b
解答:
これらのプログラムの両方は自分自身のコードとデータをアドレスに紐づいたセグメントやページ番号なしで参照できるプログラムに帰着される。MULTICSはそれぞれのプロセスに4つのレジスタを関連付けることでこの問題を解決した。あるレジスタは現在のプログラムセグメントのアドレスを保持、別のレジスタはスタックのベースレジスタのアドレスを保持、別のレジスタはグローバルデータのベースアドレスを保持、など。すべての参照は現在のセグメントやページ番号にマッピングする特定のレジスタを介して間接的に行う。これらのレジスタを変更することで同じコードが別のプロセスで動き、同じページやセグメント番号にする必要がない。

8.8 In the IBM/370, memory protection is provided through the use of keys. A key is a 4-bit quantity. Each 2K block of memory has a key (the storage key) associated with it. The CPU also has a key (the protection key) associated with it. A store operation is allowed only if both keys are equal, or if either is zero. Which of the following memory-management schemes could be used successfully with this hardware?
a. Bare machine
b. Single-user system
c. Multiprogramming with a fixed number of processes
d. Multiprogramming with a variable number of processes
e. Paging
f. Segmentation
回答:
解答:a 保護が必要ないのでキーを0にする
b 特権モードではキーを0にする
c 領域サイズを2kBの倍数とし、メモリブロックにキーを割り当てる
d 同上
e フレームサイズを2kBの倍数とし、ページにキーを割り当てる
f セグメントサイズを2kBの倍数とし、セグメントにキーを割り当てる

  1. アドレス空間のサイズをビットで表すという問題じゃなかったですね…

コメント

タイトルとURLをコピーしました