Chapter 5 Input/Output 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks 5.5 Clocks 5.6 Character-oriented terminals 5.7 Graphical user interfaces 5.8 Network terminals 5.9 Power management 1 Memory-Mapped I/O (1) Separate I/O and memory space Memory-mapped I/O Hybrid 2 1
Memory-Mapped I/O (2) (a) A single-bus architecture (b) A dual-bus memory architecture 3 Direct Memory Access (DMA) Operation of a DMA transfer 4 2
Interrupts Revisited How interrupts happens. Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires 5 Disks Disk Hardware (1) Disk parameters for the original IBM PC floppy disk and a Western Digital WD 18300 hard disk 6 3
Disk Hardware (2) Physical geometry of a disk with two zones A possible virtual geometry for this disk 7 Disk Hardware (3) Raid levels 0 through 2 Backup and parity drives are shaded 8 4
Disk Hardware (4) Raid levels 3 through 5 Backup and parity drives are shaded 9 Disk Hardware (5) Recording structure of a CD or CD-ROM 10 5
Disk Hardware (6) Logical data layout on a CD-ROM 11 Disk Hardware (7) Cross section of a CD-R disk and laser not to scale Silver CD-ROM has similar structure without dye layer with pitted aluminum layer instead of gold 12 6
Disk Hardware (8) A double sided, dual layer DVD disk 13 Disk Formatting (1) A disk sector 14 7
Disk Formatting (2) An illustration of cylinder skew 15 Disk Formatting (3) No interleaving Single interleaving Double interleaving 16 8
Disk Arm Scheduling Algorithms (1) Time required to read or write a disk block determined by 3 factors 1. Seek time 2. Rotational delay 3. Actual transfer time Seek time dominates Error checking is done by controllers 17 Disk Arm Scheduling Algorithms (2) Initial position Pending requests Shortest Seek First (SSF) disk scheduling algorithm 18 9
Disk Arm Scheduling Algorithms (3) The elevator algorithm for scheduling disk requests 19 Error Handling A disk track with a bad sector Substituting a spare for the bad sector Shifting all the sectors to bypass the bad one 20 10
Stable Storage Analysis of the influence of crashes on stable writes 21 Chapter 6 File Systems 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems 22 11
Long-term Information Storage 1. Must store large amounts of data 2. Information stored must survive the termination of the process using it 3. Multiple processes must be able to access the information concurrently 23 File Naming Typical file extensions. 24 12
File Structure Three kinds of files byte sequence record sequence tree 25 File Types (a) An executable file (b) An archive 26 13
Sequential access File Access read all bytes/records from the beginning cannot jump around, could rewind or back up convenient when medium was mag tape Random access bytes/records read in any order essential for data base systems read can be move file marker (seek), then read or read and then move file marker 27 File Attributes Possible file attributes 28 14
File Operations 1. Create 2. Delete 3. Open 4. Close 5. Read 6. Write 7. Append 8. Seek 9. Get attributes 10.Set Attributes 11.Rename 29 An Example Program Using File System Calls (1/2) 30 15
An Example Program Using File System Calls (2/2) 31 Memory-Mapped Files (a) Segmented process before mapping files into its address space (b) Process after mapping existing file DEF into one segment creating new segment for [\] 32 16
Directories Single-Level Directory Systems A single level directory system contains 4 files owned by 3 different people, A, B, and C 33 Two-level Directory Systems Letters indicate RZQHUV of the directories and files 34 17
Hierarchical Directory Systems A hierarchical directory system 35 Path Names A UNIX directory tree 36 18
Directory Operations 1. Create 2. Delete 3. Opendir 4. Closedir 5. Readdir 6. Rename 7. Link 8. Unlink 37 File System Implementation A possible file system layout 38 19
Implementing Files (1) (a) Contiguous allocation of disk space for 7 files (b) State of the disk after files ' and ( have been removed 39 Implementing Files (2) Storing a file as a linked list of disk blocks 40 20
Implementing Files (3) Linked list allocation using a file allocation table in RAM 41 Implementing Files (4) An example i-node 42 21
Implementing Directories (1) (a) A simple directory fixed size entries disk addresses and attributes in directory entry (b) Directory in which each entry just refers to an i-node 43 Implementing Directories (2) Two ways of handling long file names in directory (a) In-line (b) In a heap 44 22
Shared Files (1) File system containing a shared file 45 Shared Files (2) (a) Situation prior to linking (b) After the link is created (c)after the original owner removes the file 46 23
Disk Space Management (1) Block size Dark line (left hand scale) gives data rate of a disk Dotted line (right hand scale) gives disk space efficiency All files 2KB 47 Disk Space Management (2) (a) Storing the free list on a linked list (b) A bit map 48 24
Disk Space Management (3) (a) Almost-full block of pointers to free disk blocks in RAM - three blocks of pointers on disk (b) Result of freeing a 3-block file (c) Alternative strategy for handling 3 free blocks - shaded entries are pointers to free disk blocks 49 Disk Space Management (4) Quotas for keeping track of each user s disk use 50 25
File System Reliability (1) )LOHWKDWKDV QRWFKDQJHG A file system to be dumped squares are directories, circles are files shaded items, modified since last dump each directory & file labeled by i-node number 51 File System Reliability (2) Bit maps used by the logical dumping algorithm 52 26
File System Reliability (3) File system states (a) consistent (b) missing block (c) duplicate block in free list (d) duplicate data block 53 File System Performance (1) The block cache data structures 54 27
File System Performance (2) I-nodes placed at the start of the disk Disk divided into cylinder groups each with its own blocks and i-nodes 55 Log-Structured File Systems With CPUs faster, memory larger disk caches can also be larger increasing number of read requests can come from cache thus, most disk accesses will be writes LFS Strategy structures entire disk as a log have all writes initially buffered in memory periodically write these to the end of the disk log when file opened, locate i-node, then find blocks 56 28
Example File Systems CD-ROM File Systems The ISO 9660 directory entry 57 The CP/M File System (1) Memory layout of CP/M 58 29
The CP/M File System (2) The CP/M directory entry format 59 The MS-DOS File System (1) The MS-DOS directory entry 60 30
The MS-DOS File System (2) Maximum partition for different block sizes The empty boxes represent forbidden combinations 61 The Windows 98 File System (1) %\WHV The extended MOS-DOS directory entry used in Windows 98 62 31
The Windows 98 File System (2) Bytes Checksum An entry for (part of) a long file name in Windows 98 63 The Windows 98 File System (3) An example of how a long name is stored in Windows 98 64 32
The UNIX V7 File System (1) A UNIX V7 directory entry 65 The UNIX V7 File System (2) A UNIX i-node 66 33
The UNIX V7 File System (3) The steps in looking up XVUDVWPER[ 67 34