Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Operating Systems

Homework Assignment# 2

1. Suppose we have a physical memory of total size 128 MB memory. This memory is organized as units ofn bytes each. For keeping track of free and occupied memory (see lecture: “Memory Management 1” slide 30 for a useful picture), we can use either linked list or bitmap. For the linked list, assume that the memory consists of an alternating sequence of segments and holes, each 64 KB. Also assume that each node in the linked list needs a 32-bit memory address, a 16-bit length, and a 16-bit next node field. For bit-map, each n bytes node needs one bit in the bitmap.

a. [2 pts] How many bytes of storage is required for linked list?

b. [2 pts] How many bytes of storage is needed for bitmap (in terms of n)?

c. [3 pts] At which values of n linked-list is better and at which value the bitmap is better, in terms of storage requirement?

2. Suppose that a machine has 38-bit virtual address and 32-bit physical addresses. (a) [2 pts] What is the main advantage of a multilevel page table over a single-level one?

(b) [3 pts]With a two-level page table, 16-KB page size, and 4-byte entries, how many bits should be allocated for the top-level page table field and how many for the next-level page table field? Explain.

3. [6 pts] For each one of the following parts, indicate whether it is accessed with virtual address or with physical address:

  TLB

  Page table

•  L1 cache memory

•  L2 cache memory

•  L3 cache memory

•  The DRAM installed in your machine (i.e. your 16GB or 32GB of RAM)

4. [4 pts] Give four advantages of virtual memory:

5. For the following piece of code:

int counter = 1;

int main() {

if (fork() == 0) {

counter--;

exit(0);

}

else {

wait(NULL);

counter++;

printf("counter = %d\n", counter);

}

exit(0);

}

Assume the above code is executed on a system with one CPU.

a. [2 pts] How many TLBs exist in the system before any process reach exit(0)”? Explain

b. [2 pts] How many Page Tables exist in the system before any process reach “exit(0)”? Explain.

Suppose we execute the above code in a system with two CPUs (i.e. a multicore with two CPUs). And that each CPU has an L1 cache of size 32KB and an L2 cache of size 1MB.

c. [2 pts] How many TLBs exist in the system before any process reach exit(0)”? Explain

d. [2 pts] How many Page Tables exist in the system before any process reach “exit(0)”? Explain.