Presentation is loading. Please wait.

Presentation is loading. Please wait.

COSC 1306 COMPUTER SCIENCE AND PROGRAMMING THE FIFTH ASSIGNMENT

Similar presentations


Presentation on theme: "COSC 1306 COMPUTER SCIENCE AND PROGRAMMING THE FIFTH ASSIGNMENT"— Presentation transcript:

1 COSC 1306 COMPUTER SCIENCE AND PROGRAMMING THE FIFTH ASSIGNMENT
J.-F. Pâris

2 Our objective We want to compare the costs of
Letting the programmer decide when to bring data in main memory through reads Having the file system manage all data transfers between the disk and the main memory

3 Why it matters Data transfers between disk and main memory are very expensive Each disk access takes around 7ms Corresponds to 10.5 million CPU cycles for a 1.5 GHz processor

4 Program-directed I/O When a program requires to access data it issues a read Most basic form is "read so many bytes from current location in this file" We call these reads sequential reads because we access the contents of the file in sequence Like reading a novel—or a manga Most programs read data a few bytes at a time Rarely more than 40 to 50 bytes, often less

5 Example Consider a program that reads 15 bytes then 20 bytes then 20 bytes again. If each read requires a disk access, we will have three disk accesses.

6 How the file system manages disk I/O
File contents are stored in fixed-size blocks Most popular block size is 4 kilobytes 4,096 bytes When a program issues a read, the file system always bring into memory at least one full block Subsequent reads can get their data from that block until the program has read one full block

7 Example Read sizes (bytes) Total Bytes brought in Disk Access 2000
4096 Yes 1000 3000 -- No 4000 500 4500 8192 6500 7500 8500 12288 9000

8 Your output should be Number of read requests: 8 Number of disk accesses: 3 Number of bytes being read: 9000 Number of bytes being brought into main memory: 12288

9 Another way to look at it
Program read requests Data actually brought in 2000 bytes 4096 bytes

10 Another way to look at it
Program read requests Data actually brought in 2000 bytes 1000 4096 bytes

11 Another way to look at it
Program read requests Data actually brought in 2000 bytes 1000 1000 4096 bytes

12 Another way to look at it
Program read requests Data actually brought in 2000 bytes 1000 1000 500 4096 bytes 4096 bytes

13 Another way to look at it
Program read requests Data actually brought in 2000 bytes 1000 1000 500 2000 bytes 4096 bytes 4096 bytes

14 Another way to look at it
Program read requests Data actually brought in 2000 bytes 1000 1000 500 2000 bytes 1000 4096 bytes 4096 bytes

15 Another way to look at it
Program read requests Data actually brought in 1000 2000 bytes 500 4096 bytes 4096 bytes 4096 bytes


Download ppt "COSC 1306 COMPUTER SCIENCE AND PROGRAMMING THE FIFTH ASSIGNMENT"

Similar presentations


Ads by Google