CSCI 4534 - Operating Systems

Assignment 2 Requirements

Page replacement algorithms

[48 points; 4 per subtask] Consider the following page-reference string:
1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6
How many page faults would occur for the page replacement algorithms listed below, assuming Remember that all frames are initially empty, so your first unique pages will all cost one fault each. The three algorithms you have to evaluate for each of the four cases above (for a total of twelve subtasks) are: For each subtask, justify your answer in the form of a diagram like the ones on figures 10.9, 10.11, and 10.12 of your textbook. Note that, as you near the end of the string, multiple choice are possible for optimal replacement. They all yield the same number of page faults, and you can make an arbitrary choice for your diagram (don't bother listing all possibilities).

Virtual memory controller

You are given an extensible simulator of a memory controller in csci4534.controller.MainSimulator. This simulator keeps track of a set of simulated processes and memory & disk contents, as processes start/stop, and as memory de/allocation and access take place. For example,
control.bat SimpleController 5:4:3:4:2 6 7 n a:0:10:rw w:0:1:2 r:0:1 d:0:0 x:0
simulates memory behaviour for a system whose physical memory capacity is 6 frames and its disk capacity is 7 blocks; each block is always the same size as a frame in our simulator. The first colon-separated list of numbers specifies the address structure supported by the (simulated) hardware. In general, the memory controller performs address translation in the style of the Intel 80386 processor under OS/2 (figure 9.21 of your textbook). A logical address has two parts, namely a segment selector followed by a segment offset; a linear address is split into three concatenated parts: p1, p2, and d. The first list of numbers specifies the length of each of those five parts in units of bits. So, in this case, we have: Keep in mind that you are building a somewhat different controller than that of the 80386 so, for example, a process contains a single segment descriptor table (instead of two --- a local and global one --- as in the 80386), and the segment selector is just the segment number (just s without a g and a p portion). The precise address translation algorithm appears in the class comments of the provided csci4534.controller.AddressTranslation stub.

In addition to the system configuration, the above command-line specifies a series of memory operations:

  1. We first create a new process. In response, the simulator displays the ID it assigns to the process, presumably 0 in this case. The process ID is supplied as the first argument to all other operations.

  2. We then allocate a segment for this process. The segment's length (limit) is 16 bytes (10 in hex), and we allow both reads from the segment and writes into the segment. In response, the simulator displays the segment number the controller assigns to the segment, presumably 0 in this case. The explicit segment number is used only to deallocate the segment (see below); it is not explicitly stated during memory references, though the (simulated) hardware derives it from each logical address issued by a process.

  3. We then write onto logical address 1 of process 0 the value 2, and then read it back out. Logical addresses are specified in hex, like segment lengths.

  4. We then deallocate segment 0 (second argument) of process 0 (first argument).

  5. Finally, we terminate process 0.
For the above input, here is the output we get (after making sure the simulator is first compiled via make.bat):
Controller: csci4534.controller.SimpleController
Creating process: 0
Allocating length 10 access rw for process 0: 0
w@0:1=2
r@0:1=2
Deallocating 0 for process 0: done
Terminating process 0: done
Memory: [0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Disk: [(0,0,0,0);(0,0,0,0);(0,0,0,0);(0,0,0,0);(0,0,0,0);(0,0,0,0);(0,0,0,0)]
You are given the implementation of a simple controller in csci4534.controller.SimpleController; in general, you can substitute SimpleController on the command-line with any other implementation of the csci4534.controller.Controller interface. The simple controller allows each process to have at most one segment, which is allocated in a contiguous hole in memory. No paging is used, and there is no virtual memory. So this controller does not take advantage of the full (simulated) 80386 hardware. Instead, the logical address is treated as a simple direct offset into the single segment of the process; we don't even extract a segment selector from the logical address since the process has at most one segment (so there is no selection to be made). This controller illustrates that it is common to see new hardware run an operating system that does not fully use the hardware capabilities; this is because there is a time lag between the production of new hardware and the corresponding OS upgrades to fully use the new hardware features.

Study Controller and the provided implementation SimpleController, along with the rest of the provided code, and pay particular attention to the following:

After you have finished studying the provided code, carry out the following tasks:

[10 points] Implement csci4534.controller.ControllerConfiguration. Please note the constraints on the nature of computations you may invoke in this class, as stated in the class comments. This constraint applies only to Java code you write yourselves; beyond this, you have no control over what instructions the JVM sends to the real CPU in the course of running your Java code.

[15 points] Implement AddressTranslation. Please note the constraints on the nature of computations you may invoke in this class, as stated in the class comments.

[20 points] Implement csci4534.controller.PhysicalController. This controller does not support virtual memory; all pages reside in physical memory only. While the (simulated) hardware supports virtual memory (since page table entries set aside space to store a disk block index), the controller does not use the hardware to the fullest possible extent (much like SimpleController doesn't). As an example of this controller's operation, the command-line

control.bat PhysicalController 2:3:2:2:1 8 8 n a:0:3:rw w:0:0:1 w:0:1:2 a:0:3:rw w:0:8:3 w:0:9:4
should produce the following output:
Controller: csci4534.controller.PhysicalController
Creating process: 0
Allocating length 3 access rw for process 0: 0
w@0:0=1
w@0:1=2
Allocating length 3 access rw for process 0: 1
w@0:8=3
w@0:9=4
Memory: [1,2,0,0,3,4,0,0,0,0,0,0,0,0,0,0]
Disk: [(0,0);(0,0);(0,0);(0,0);(0,0);(0,0);(0,0);(0,0)]
[15 points] Implement csci4534.controller.VirtualController. This controller supports virtual memory, and is an extension of PhysicalController you just built. This controller takes full advantage of the hardware. As an example of this controller's operation, the command-line:
control.bat VirtualController 2:3:2:2:2 2 4 n a:0:4:rw w:0:0:1 w:0:1:2 a:0:4:rw w:0:8:3 w:0:9:4 a:0:4:rw w:0:10:5
should produce the following output:
Controller: csci4534.controller.VirtualController
Creating process: 0
Allocating length 4 access rw for process 0: 0
w@0:0=[DR:0->0]=1
w@0:1=2
Allocating length 4 access rw for process 0: 1
w@0:8=[DR:1->4]=3
w@0:9=4
Allocating length 4 access rw for process 0: 2
w@0:10=[DW:0->0]=[DR:2->0]=5
Memory: [5,0,0,0,3,4,0,0]
Disk: [(1,2,0,0);(0,0,0,0);(0,0,0,0);(0,0,0,0)]
The notation [DR:d->m] show a disk read from disk block index d to memory at physical address m, and the notation [DW:m->d] show a disk write from memory to disk.

Make sure all your code is well documented in the same simple, succinct style that the provided code is documented. As the syllabus states, points will be deducted for poorly commented code you write for this or any other programming task in this course.

[1 point] How much time did you spend on this section?


[1 point] Summarize in a concise list the key concepts and/or technologies that this assignment helped you digest. You don't have to explain the listed items; just name them.
© 2004 Apostolos Lerios