Next: About this document ...
CS423UG Homework 4 Solution
November 7, 2005
- (4.5)
- first fit
(a) 20KB
(b) 10KB
(c) 18KB
- best fit
(a) 12KB
(b) 10KB
(c) 9KB
- worst fit
(a) 20KB
(b) 18KB
(c) 15KB
- next fit
(a) 20KB
(b) 18KB
(c) 9KB
- (4.15)
- one-level
Each 4KB page has
bytes. Therefore, the computer has
virtual pages. In a one-level page table,
all virtual pages need an entry. Therefore, the number of page table
entries needed is
.
- two-level
The first-level table has
entries, each of which points to a
second-level table. Each second-level table has
entries, each
pointing to a 4KB page. From the assumption of this question, the
program text and data pages are pointed by the same second-level
table, while the stack pages need another table.
Therefore, we need one first-level page, and two second-level pages,
which gives us the total number of page table entries
.
- (4.16)
- Page reference string
Load word at location 6144 into register 0
Inst. Addr: 1020, Data Addr: 6144
Push register 0 onto the stack
Inst. Addr: 1024, Data Addr: 8188
Call a procedure at 5120, stacking the return address
Inst. Addr: 1028, Data Addr: 8184 (to store return addr.)
Subtract the immediate constant 16 from the stack pointer
Inst. Addr: 5120, Data Addr: nil.
Compare the result of previous operation to the immediate constant 4
Inst. Addr: 5124, Data Addr: nil.
Jump if equal to 5152.
Inst. Addr: 5128, Data Addr: nil.
So the sequence of addresses generated are: 1020, 6144, 1024, 8188,
1028, 8184, 5120, 5124, 5128.
Given that the page size is 512 bytes, the corresponding page
reference string is 1, 12, 2, 15, 2, 15, 10, 10, 10.
- Number of page faults under LRU with 3 frames
Total 5 page faults (1st, 2nd, 3rd, 4th, 7th)
- (4.31)
- 4096-byte page
65536-byte address space is composed of 16 pages. On the other hand,
program text is 8 pages, data is 5 pages, and stack requires 4 pages.
Since it requires total 17 pages, it does not fit to physical memory.
- 512-byte page
65536-byte address space is composed of 128 pages. On the other hand,
program text is 64 pages, data is 33 pages, and stack requires 31 pages.
Since it requires total 128 pages, it fits to physical memory.
- (5.11)
- floppy disk
Average time to transfer 1 sector is 77 (average seek time) + 100
(half rotation time) + 22 (transfer time) = 199ms. Since 1 sector
has 512 bytes, this gives us 20.58kbps as follows, which is slower than
56kbps modem.
- hard disk
Average time to transfer 1 sector is 6.9 (average seek time) + 4.165
(half rotation time) + 0.017 (transfer time) = 11.08ms. Since 1 sector
has 512 bytes, this gives us 369.61kbps as follows, which is faster
than 56kbps modem, yet slower than 100Mbps fast ethernet.
- (5.12)
A packet is copied for 4 times during this process. There are also two
interrupt. Therefore, along with the transmission delay, it takes 6.9152ms
to pump one 1024-byte packet, as follows.
Therefore, the maximum data rate is
1.185Mbps.
- (5.24)
- FCFS
The arm accesses in the order of 10, 22, 20, 2, 40, 6, 38, which
gives
ms
- Closest cylinder first
The arm accesses in the order of 20, 22, 10, 6, 2, 38, 40, which
gives
ms
- Elevator algorithm (initially moving forward)
The arm accesses in the order of 20, 22, 38, 40, 10, 6, 2, which
gives
ms
- We can use soft timer for polling I/O in the same idea for the clock.
Whenever the system enters kernel mode, the soft-timer facility checks
for any pending I/O events before it exits, and invokes the associated
handlers when appropriate.
The advantage of this scheme is same as the original one. It reduces
number of interrupts because it avoids interrupts when kernel is
running. Thus, this scheme can avoid the overhead of interrupts.
However, this scheme can be disadvantageous especially for high-frequency devices, as I/O requests now cannot be processed when the system does not
enter the kernel mode. This leads some delay for such requests. Also,
the polling time increases linearly as the number of devices increases.
Next: About this document ...
Jintae Kim
2005-11-05