Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS623: Lecture 4 2/17/2004 © Joel Wein 2003, modified by T. Suel.

Similar presentations


Presentation on theme: "CS623: Lecture 4 2/17/2004 © Joel Wein 2003, modified by T. Suel."— Presentation transcript:

1 CS623: Lecture 4 2/17/2004 © Joel Wein 2003, modified by T. Suel

2 Review of I/O - Key Issues Current performance battleground: – Processor speeds increasing, SMPs coming – Internal memory getting faster, multi-level caches – I/O to disk lags behind – But not capacity: data sets growing with disks File Systems: – Performance – Reliability – Security – Distributed File Systems

3 Organization of the I/O Function Programmed I/O: – I/O-to-memory transfer through processor. – Processor issues an I/O command, on behalf of process, to an I/O module. Process busy-waits for operation to be completed before proceeding. Interrupt-Driven I/O: – Processor issues I/O command on behalf of process, continues to process, is interrupted by I/O module when done “synchronous vs. asynchronous I/O”

4 Organization of the I/O Function Direct Memory Access: – Direct I/O to Memory transfer – DMA module controls exchange of data between main memory and I/O module. – Processor interrupted only after entire block has been transferred.

5 Evolution of I/O Function 1. Processor directly controls a peripheral device. 2. Controller or I/O module added. Proc uses programmed I/O w/o interrupts. Proc becomes somewhat divorced from details of external device interfaces 3. Add interrupts. Processor does not need to wait for I/O to happen 4. I/O module is given direct control of memory via DMA. Can now move a block of data to or from memory without involving the processor, except at the beginning and end of each transfer. 5. I/O module is enhanced to become a separate proc 6. I/O module has local memory and is own computer

6 OS Design Issues Design Objectives – Efficiency Generality – handle devices in a uniform fashion. – Hierarchical, modular approach – Hide most of details of device I/O in lower-level routines Logical Structure of I/O Function

7 Logical I/O: deal with device as logical resource and not concerned with details of controlling the device Device I/O: Requested operations and data are converted into appropriate sequences of I/O instructions, channel commands and controller orders. Scheduling and Control: Actual queueing and scheduling of I/O operations. See Figure 11.5

8 Additional Layers Directory Management – Symbolic file names converted to identifiers that reference file directly or indirectly through file descriptor or index table. File system: – Logical structure of files, operations that can be specified by users, such as open, close, read, write. Access rights managed here too. Physical Organization

9 I/O Buffering Suppose we are reading blocks of data from tape one at a time: – Program has to wait for I/O, may be swapped out – Approach to I/O interferes with OS swapping decisions. Target locations must remain in main memory. Impossible to completely swap the process out. – If swap out could get a single-process deadlock. Process issues I/O command, suspended awaiting result, swapped out waiting. Process blocked waiting on I/O, I/O blocked waiting for it to be swapped in.

10 must lock certain areas of memory involved in I/O try to ameliorate by doing input transfers in advance of requests made and to perform output transfers sometime after a request is made

11 Single Buffering When user process issues I/O request, OS assigns a buffer in system portion of main memory to the operation. – Input transfers made to system buffer – When transfer complete, moved to user space, – Immediately request another block – anticipated input. Advantages: – Speedup – Can swap process out because I/O to system memory, not user space Double Buffer: A process transfers data to one buffer while the OS empties or fills the other

12 Circular Buffer Double buffering may be inadequate if process performs rapid bursts of I/O. Use multiple buffers. NOTE: No amount of buffering will allow an I/O device to keep pace with a process indefinitely when average demand of process is greater than I/O device can service – Even with multiple buffers, all of the buffers will eventually fill up and the process will have to wait after processing each chunk of data. – In a multiprogramming environment, when there is a variety of I/O activity, etc., it can help

13 I/O systems function using disk hardware Drive Geometry – Disks are designed as circular platters stacked one on top of another – Tracks are defined in each disk as circular structures at some predefined radius – Sectors are one slice of a track – Cylinders are one set of tracks across all the disks

14 Disk Scheduling Seek time: – Startup time, traversal time, settling time – Average seek time “today:” 5 to 10 ms. Rotational Delay – 5400 to 10000 rpm – 10000 rpm = one revolution per 6 ms; average rotational delay 3ms. Transfer time to or from disk: bytes/(Bytes per Track)*Rotation Speed (RPS)

15 Example 1 Average seek time: 10 ms Rotational Speed: 10,000 RPM Format Characteristics: – 512 Bytes/Sector – 320 Sectors/Track Read a file of 1,310,720 (1.3MB) – two cases: a) it’s fully sequential – 8 tracks, 8x320=2560 sectors. b) it’s 100% fragmented (Random access)

16 Fully sequential 2560 Sectors Average seek: 10ms Rotational delay: 3 ms Read 320 sectors: 6 ms. So, time to read 1 st track = 19 ms. Suppose rest of tracks have no seek time. 19 + 7*9 =.082 seconds.

17 Random Average seek 10 ms Rot delay 3 ms. Read 1 sector 0.01875 ms 2560 x 13.01875ms = 33.328 sec. Order in which sectors read from disk makes a difference Important to keep files “together” on disk

18 Disk Scheduling Policies: Queue/Requestor-Based Random – Select items from queue in random order (bad) FIFO – Process items from queue in seq. order; fair. – Good if a few processes do access to clustered file sectors – If many processes competing for disk, approaches random Priority – Does not optimize disk utilization but meets other objectives within the OS LIFO – Always take most recent request – Great for a sequential file – Starvation possible

19 Disk Scheduling Policies: Advanced SSTF– choose I/O request with least seek time. Better than FIFO (all these algos except for FIFO can have starvation) SCAN: – Arm moves in one direction, satisfying all outstanding requests. – When hits last request, turns around. – LOOK policy: Stop early if no more requests – Also called elevator

20 More policies: C-SCAN: Restricts scanning to one direction only N-step-SCAN, FSCAN – SSTF, SCAN,C-SCAN can all have “arm stickiness”, monopolizing device by repeated requests to close-by tracks – segment disk-request queue in segments of size N: one segment at a time processed completely. – FSCAN: All new requests in 2 nd queue during scan

21 File Management - Terms Field: Basic element of data; could be fixed or variable-length. Record: collection of related fields that can be treated as a unit by some application File: collection of similar records Database: collection of related data. – Relationships are made explicit in database. Operations: – Retrieve_all/One/Next/Previous – Insert_One/Delete_One/Update_One – Retrieve_Few

22 File System Architecture Device Drivers: communicate directly with peripherals Basic file system/physical I/O – Blocks of data that are exchanged with disk and tape systems. – Deals with placements of those blocks on secondary storage device and on buffering of these blocks. No notion of content or structure of files involved.

23 File System Architecture (cont.) Basic I/O Supervisor: – File I/O initiation and termination – Scheduling disk and tape accesses to optimize performance. Logical I/O: Enable users and applications to access records. Deals with file records, not general blocks of data.

24 File Organization and Access file organization: logical structuring of records as determined by the way they are accessed Criteria: – Rapid access – Ease of update – Economy of storage – Simple maintenance – Reliability can be at tension: – Economy of storage v. rapid access


Download ppt "CS623: Lecture 4 2/17/2004 © Joel Wein 2003, modified by T. Suel."

Similar presentations


Ads by Google