Title: Operating Systems
1- Operating Systems
- I/O Management and File Systems
2I/O Management and File Systems
- Topics
- 1. I/O Management and File Systems
- 2. Where I/O Fits In
- 3. I/O Device Types
- 4. Device Type Features
- 5. Architectural Support for I/O in
- Systems
- 6. Evolution of I/O Functions
- 7. Bus Support for DMA Control
3- Topics (continued)
- 8. DMA and Busy Cycles
- 9. DMA Configurations
- 10. DMA Channels
- 11. Buffering
- 12. Buffering Performance
- 13. Anatomy of a Disk
- 14. Raw Disk Sector Addressing
- 15. Access Performance of Disks
- 16. Disk Scheduling Policies
4- Topics (continued)
- 17. Disk Free Space Management
- 18. Disk Block Allocation Methods
- 19. Contiguous Allocation
- 20. Linked Allocation
- 21. File Allocation Tables
- 22. Indexed Schemes
- 23. Unix File System Layout
- 24. Unix INODE Usage
5Where I/O Fits In
- I/O devices (also called peripherals) are
- the third part of the von Neumann
- architecture.
- Peripherals are responsible for permitting
- the computer to exchange information
- with its external environment.
6Memory
CPU
0
PC
MAR MBR I/O AR I/O BR
1
IR
Instructions
Instructions
ALU
Data Data Data
Buffers
(Persistent Store and
interface devices)
Peripherals
7I/O Device Types
- I/O devices may communicate with either
- devices or users. Devices can be
- categorized according to what they
- interface with
- 1. Human Readable
- 2. Machine Readable
- 3. Data Communication
8Device Type Features
- Devices differ according to their
- 1. Data rate
- 2. Application
- 3. Control complexity
- 4. Unit of transfer
- 5. Data Representation
- 6. Error Conditions
- 7. Storage media
- 8. Removeability of media
9Architectural Support for I/O in Systems
- Historically the choices for I/O support
- included
- 1. Programmed I/O
- 2. Interrupt Driven I/O
- 3. Direct Memory Access (DMA)
- The current trend for block oriented
- devices is DMA.
10Evolution of I/O Functions
- Traditionally users make a system call to
- get I/O.
- The following methods are used
- 1. Direct Processor Controlled I/O
- 2. Polling Software Module Level Control
- 3. Interrupt Driven Software Module
- Level Control
- 4. Interrupt Driven DMA
-
11Evolution of I/O Functions (continued)
- 5. Separate I/O Processor using Main
- Memory
- 6. Separate I/O Processor with Local
- Memory
- Disk controllers and modern network
- cards all into the last category.
12Bus Support for DMA Control
- The data bus typically needs to be
- augmented with additional lines to
- support DMA.
13Data Count
Data Lines
Data Register
Address Register
Address Lines
DMA Req DMA ACK INTR Read Write
Control Logic
Figure 2 A typical DMA Block Diagram
14DMA and Busy Cycles
- The bus scheduling for DMA access is
- typically more flexible than for an
- interrupt. DMA just has to block memory
- access, interrupts have to avoid
- instruction restart whenever possible.
15DMA vs. Interrupt Scheduling
Instruction Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Fetch Instruction
Decode Instruction
Fetch Operand
Execute Instruction
Store Result
Process Interrupt
DMA Breakpoints
Interrupt Breakpoints
16DMA Configurations
- DMA can either share a common bus with
- the CPU or it can be detached, or it can
- have its own bus.
17Some Popular DMA Configurations
DMA Module
...
I/O
CPU
CPU
Memory
(a) Single-bus, detached DMA
18DMA Module
DMA Module
CPU
Memory
I/O
I/O
I/O
(b) Single-bus, integrated DMA-I/O
19System Bus
DMA Module
CPU
Memory
I/O Bus
I/O
I/O
I/O
(c) I/O bus
20DMA Channels
- Systems requiring sustained I/O
- bandwidth may give DMA controllers
- dedicated channels, with instruction
- streams flowing to the controllers
- along the channels. Multiplexors can can
- be used to select the I/O channel.
21Data and Address Channel to Main Memory
Selector Channel
Control Signal Path to CPU
...
I/O Controller
I/O Controller
22To Memory
(a) Selector
Multi- plexor Channel
I/O Controller
To CPU
I/O Controller
I/O Controller
I/O Controller
23Buffering
- Hardware and software can use buffering
- to store data in fast memory pending I/O
- to overcome latency.
24Operating System
User Process
I/O Device
In
(a)No buffering
Operating System
User Process
I/O Device
In
Move
(b)Single buffering
25Operating System
User Process
I/O Device
In
Move
(c)Double buffering
26Operating System
User Process
I/O Device
In
Move
. . .
(d)Circular buffering
27Buffering Performance
- Let
- M be the time for a memory copy,
- C be the the computing time between input
requests, and - T be the time to transfer a block out to the
peripheral. - The cost of unbuffered I/O is TC.
- The cost of a buffered I/O is max(C,T)M.
28Buffering Performance (continued)
- Historically MltltT however recent trends
- in high performance computing have
- determined that excessive copying
- degrades performance in practice.
- In general buffering levels out I/O
- performance over short term variations.
29Anatomy of a Disk
- Hard disks (also called Winchester disks)
- are often the large capacity media of
- choice in modern systems.
30Hard Disk Components
Track t
Arm
Cylinder
Read/write heads
Rotation
31Raw Disk Sector Addressing
- Typically the sectors on a disk are
- assigned sequential addresses along the
- tracks, let be the block address of a
- sector.
32Parameter b i j k s t
Meaning The block address (to find) cylinder of
sector surface of sector position of sector
within its track number of sectors per
track track/cylinder number
Table 1 Parameters of Sector Computation
b k s x ( j i x t ) 1
33Access Performance of Disks
- Seek time is the time to move the arm to
- the desired track. Let Ts be the seek time,
- n be the number of tracks traversed, m
- be the time to traversing a single track,
- and s be the startup time, then
- Tsm x n s 2
34Access Performance of Disks (continued)
- Transfer time is the time it takes to scan
- the information off the disk,
- letting T be the transfer time, and b be the
- number of bytes to transfer, N be the
- sector size in bytes, and r be the
- revolutions per seconds, then
- T (3)
b rN
35Access Performance of Disks (continued)
- The average access time, Ta is
- Ta Ts (4)
1 2r
b r N
36Disk Scheduling Policies
- In practice disk access times are highly
- sensitive to the previous head position.
- Most disk scheduling algorithms focus
- on this.
37Some Disk Schedules
0
25
50
75
100
125
150
175
199
Time
(a) FIFO
380
25
50
75
100
125
150
175
199
Time
(b) SSTF
390
25
50
75
100
125
150
175
199
Time
(c) SCAN
400
25
50
75
100
125
150
175
199
Time
(d) C-SCAN
41Disk Free Space Management
- Available space needs to be found
- quickly for storage. Typically blocks are
-
- 1. Corrupted --- Hardware failure, not
- available for use
- 2. Free
- 3. Used
42Disk Free Management (continued)
- Typically either bitmaps are used, or a
- list structure, sometimes with run length
- encoding (assuming larger contiguous
- spaces). The list structure may be
- contiguous or linked.
- The lists are stored starting in a fixed
- block within the partition (for uniform
- access at boot time), and may chain into
- other blocks.
43Disk Block Allocation Methods
- 1. Contiguous
- 2. Linked List (and FAT)
- 3. Indexed
44Contiguous Allocation
- This requires that a file n blocks long
- occupy n contiguous blocks. External
- fragmentation and file placement are
- difficult problems.
45A Contiguous Allocation Scheme
count
0
1
2
3
4
5
6
7
8
9
10
11
directory
12
13
14
15
File
Start
Length
16
17
18
19
Count tr mail list f
0 14 19 28 6
2 3 6 4 2
mail
20
21
22
23
24
25
26
27
list
28
29
30
31
46Linked Allocation
- Each block maintains a pointer to the
- next block, with an entry in the system
- directory block for the head of each file.
- Free blocks get placed on a special free
- linked list. Performance can be bad due
- to excessive seeks.
47A Linked Allocation Scheme
0
1
2
3
directory
4
5
6
7
File Start End
8
9
10
11
Jeep 9 25
12
13
14
15
16
17
18
19
key
20
21
22
23
1
10
24
25
26
27
16
-1
28
29
30
31
25
48File Allocation tables
- File allocation tables use a linked list
- stored in a table with one entry per block
- in a dedicated block on the partition. This
- is used in MS-DOS, OS/2 and MS
- Windows (probably NT too). Redundant
- storing of the links on disk provides a
- recovery mechanism.
49File Allocation Table
Scheme (FAT)
Directory entry
0
. . .
test
217
217
name
Start block
618
End-of-file
339
618
339
No. of disk blocks -1
FAT
50Indexed Schemes
- Each file has an index block which is an
- array of pointers to contiguous disk
- regions. When a file is allocated all index
- pointers are initialized to. As space is
- needed, blocks are appended to the index
- tree structure.
- Some options include
- 1. Linked
- 2. Multilevel Indexed
- 3. Combined
51Unix File System Layout
- The Unix file system dedicates low order
- blocks in a partition for
- 1. Boot Block --- For bootable
- partitions.
- 2. Superblock --- The root of the file
- system's Inode hierarchy.
- 3. Inodes --- Indices to blocks on disk
- for the file system.
52Unix File system Partitions
Disk drive
partition
partition
partition
file-system
i-list
Directory blocks and data blocks
boot block(s)
. . .
i-node
i-node
i-node
super block
5317.6 - Unix INODE Usage
The INODES form a Btree of the blocks
in a file.
directory blocks and data blocks
i-list
data lock
data lock
directory block
data lock
directory block
filename
i-node
i-node
i-node
i-node
i-node
1st data block
filename
i-node
2nd data block
3rd data block
54Unix INODE Usage
- Directory blocks contain Inode
- information for files in the directory. The
- Unix file system is a directed rooted
- graph (but not a tree or DAG). Partitions
- can be added by mounting them (i.e.
- inserting them into the directory
- structure). MS-DOS does not have
- mounting.
55Figure 14 Inodes and directories in
the Unix file system
directory blocks and data blocks
i-list
directory block
directory block
.
1267
.
. .
i-node
2549
. .
1267
2549
testdir
i-node 0
i-node 1267
i-node 2549
data block