# CS3013 Homework B

Due date: Wednesay, October 12th, 4pm

You must turn in your homework in written form by the time it is due. Note, there are no late-dates allowed for this homework since a solution will be posted on the afternoon it is due to help with exam preparation.

The questions are based on material presented in class and reading material from the text.

Give brief answers to the following questions:

1. Briefly explain why segmentation (without paging) is similar to variable sized memory management. Explain why it is different.

2. Consider the following page-reference string for one process:

```1,2,3,4,2,1,5,6,3,1,3,6,7,2,4,2,1,3,6
```
How many page faults would occur for the below replacement algorithms, assuming a total 4 frames available for the process. Assume pure demand paging (all frames are initially empty), so the first page faults will all cost one fault each.

• First In First Out (FIFO) replacement
• Least Recently Used (LRU) replacement
• Optimal replacement
3. Consider the following page-reference string for one process:

```1,2,3,4,2,1,5,6,3,1,3,6,7,2,4,2,1,3,6
|   |
X   Y
```
Assume a past window interval of 5 page references.

• What are the working sets for the process at time X and at time Y?
• Assuming a total 4 frames available for the process, would it be thrashing at time X? How about at time Y? Explain.
• If there is thrashing, what is the minimum number of frames that need to be assigned to the process to avoid thrashing?
4. Briefly compare and contrast hard page faults with soft page faults.

5. Consider a demand-paging system with the page table stored in memory. The memory access time is 100 nanoseconds, then average soft page fault service time of 1 millisecond and the average hard page fault service time of 20 milliseconds. Currently, the system has a 30% page fault rate of which 70% are hard page faults. What is the effective memory access time?

6. Consider the following file distribution on a disk cylinder:

```Cylinder:  1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18
Files:     x     x        x              x  x        x     x  x
Req order: 3     6        1              4  2        8     5  7
```
The time to move the disk arm between each cylinder is 1ms and the disk arm is currently located at cylinder 13 (and was moving up). Assuming that all the read requests are already made prior to the disk scheduling, calculate the average seek times for the following arm scheduling algorithms:

1. FCFS scheduling
2. SSF scheduling
3. Elevator (SCAN) scheduling