--- Matthew Karpeles 2007/11/22 13:30 --- Rogelio Vargas 2007/11/25 15:30 --- Tim Cherry 2007/11/25 16:00
| Write Request | Request Concatenation | |
|---|---|---|
| write(1, "A") | write(1, "XBC", 3) | |
| write(1, "B") | ||
| write(1, "C") | ||
| seek(fd, SEEK_SET, 0) | ||
| write(1, "X") | ||
This shows how a group of write requests can be combined into a single request in order to improve utilization.
A Dirty Block is a block whose in-memory version is NEWER than the copy on disk. If a disk has a dirty block then we have work to do in the future (write data back to the disk), but in what order?
The two main reasons are because multiple processes can request to read and or write to a disk at a time which leads to requests being created faster than they can be serviced. And secondly because of the techniques of prefetching and batching (in order to reduce seek time in disks), reads and writes of sectors are typically performed in groups. Disk scheduling is a method used to decide the order of writing or reading disk blocks. Because of the number of requests that can exist within a system scheduling requests can have an important effect on performance. The cost of reading or writing to disk is significant and the cost is due to the sweep performed by the arm of the drive, called the seek time. The cost of or number of sweeps can be reduced by the using different disk scheduling algorithms in an effort to achieve better performance.
The OS has a set of dirty blocks and it has to decide in what order to write these blocks. Unlike processes context switching, in writing blocks of data seek times vary in the amount of time required. In comparing scheduling of processes and disks we can make the comparison of context switch in processes to seek time in disks.
Seek Time Model
S(B1, B2) = { 1 if B2 = B1 + 1, 1000 x | B2-B1 | otherwise };
In a FCFS disk scheduling algorithm, we read or write blocks in the order they are requested. Using the Seek Time Model here is an example schedule:
| Requested Blocks | ||||||
|---|---|---|---|---|---|---|
| 0 | 10 | 1 | 11 | 2 | 12 | |
=> Cost = 10,000 + 9,000 + 10,000 + 9,000 + 10,000
= 48,000 units of time
The basic idea is that at each step we write the block that is closest to the disk head position in terms of seek time.
Using the same Example we can can calculate the cost: => Cost = 1 + 1 + 8,000 + 1 + 1
= 8,004 units of time
It employs the same basic idea of SSTF but eliminates starvation.
The idea is that the elevator makes a pass of the entire building in a single direction. Seek first in the shortest direction meaning if 4 pushes up, then 2 pushes up and finally 3 pushes down, the order in which they are serviced is as follows. 2 gets picked up first, then 4 gets picked up and once these two are dropped off then as the elevator goes back down, 3 gets picked up.
Note : This presents a possible contradiction, since we can't write to a data block and the bitmap at the same exact time. If we were to write to the bitmap before writing to a data block then we break 4. If we write to the data block before the bitmap then we break 3. So What do we do?
We must develop a method to ensure robustness against possible write/disk failures. Then we ensure this by implementing a combination of the following:
Golden Rule of Atomicity : Never modify the only copy of a large consistent object.
Commit Record : Did the entire sequence of writes/updates succeed or fail?
Write-ahead logs/ Journaling
--- Matthew Karpeles 2007/11/22 15:29 --- Rogelio Vargas 2007/11/25 15:30 --- Tim Cherry 2007/11/25 16:00