operating systems i/o management and file systems operating systems i/o management and file systems
TRANSCRIPT
Operating Systems
I/O Management and File Systems
Operating Systems
I/O Management and File Systems
I/O Management and File SystemsI/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
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
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
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
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
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
Where I/O Fits InWhere 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.
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.
MARMBRI/O ARI/O BR
PC
IR
ALU
InstructionsInstructions
DataDataData
01
MemoryCPU
Buffers
(Persistent Store and interface devices)
Peripherals
I/O Device TypesI/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
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
Device Type FeaturesDevice 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
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
Architectural Support for I/O in Systems
Architectural 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 orienteddevices is DMA.
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 orienteddevices is DMA.
Evolution of I/O FunctionsEvolution 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
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
Evolution of I/O Functions (continued)Evolution 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.
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.
Bus Support for DMA ControlBus Support for DMA Control
The data bus typically needs to be
augmented with additional lines to
support DMA.
The data bus typically needs to be
augmented with additional lines to
support DMA.
Data Count
DataRegister
AddressRegister
ControlLogic
Data Lines
Address Lines
DMA ReqDMA ACK
INTRReadWrite
Figure 2:A typical DMA Block Diagram
DMA and Busy CyclesDMA 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.
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.
DMA vs. Interrupt Scheduling
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Processor Cycle
Instruction Cycle
Fetch Instruction
Decode Instruction
Fetch Operand
Execute Instruction
Store Result
Process Interrupt
DMA Breakpoints
Interrupt Breakpoints
DMA ConfigurationsDMA Configurations
DMA can either share a common bus with
the CPU or it can be detached, or it can
have its own bus.
DMA can either share a common bus with
the CPU or it can be detached, or it can
have its own bus.
Some Popular DMA ConfigurationsSome Popular DMA Configurations
DMA ModuleCPU CPU I/O Memory...
(a) Single-bus, detached DMA(a) Single-bus, detached DMA
I/O
CPUDMA Module
DMA Module Memory
I/O I/O
(b) Single-bus, integrated DMA-I/O(b) Single-bus, integrated DMA-I/O
I/O
CPUDMA Module Memory
I/O I/O
(c) I/O bus(c) I/O bus
System Bus
I/O Bus
DMA ChannelsDMA 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.
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.
Data and Address Channelto Main Memory
Control SignalPath to CPU
SelectorChannel
I/OController
I/OController
...
To Memory
To CPU
Multi-plexorChannel
I/OController
I/OController
I/OController
I/OController
(a) Selector(a) Selector
BufferingBuffering
Hardware and software can use buffering
to store data in fast memory pending I/O
to overcome latency.
Hardware and software can use buffering
to store data in fast memory pending I/O
to overcome latency.
In
User Process
Operating System
I/O Device
(a)No buffering
In
User Process
Operating System
Move
I/O Device
(b)Single buffering(b)Single buffering
I/O Device
In
User Process
Operating System
Move
(c)Double buffering(c)Double buffering
I/O Device
InMove ...
Operating System
(d)Circular buffering(d)Circular buffering
User Process
Buffering PerformanceBuffering PerformanceLet• 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 T+C.
The cost of a buffered I/O is max(C,T)+M.
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 T+C.
The cost of a buffered I/O is max(C,T)+M.
Buffering Performance (continued)Buffering Performance (continued)
Historically M<<T 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.
Historically M<<T 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.
Anatomy of a DiskAnatomy of a Disk
Hard disks (also called Winchester disks)
are often the large capacity media of
choice in modern systems.
Hard disks (also called Winchester disks)
are often the large capacity media of
choice in modern systems.
Hard Disk ComponentsHard Disk Components
Arm
Read/write heads
Track t
Cylinder
Rotation
Raw Disk Sector AddressingRaw Disk Sector Addressing
Typically the sectors on a disk are
assigned sequential addresses along the
tracks, let be the block address of a
sector.
Typically the sectors on a disk are
assigned sequential addresses along the
tracks, let be the block address of a
sector.
Parameter
bijkst
Meaning
The block address (to find)cylinder of sectorsurface of sector
position of sector within its tracknumber of sectors per track
track/cylinder number
Table 1: Parameters of Sector Computation
b = k + s x ( j + i x t ) [1]b = k + s x ( j + i x t ) [1]
Access Performance of DisksAccess 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:
Ts=m x n + s [2]
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:
Ts=m x n + s [2]
Access Performance of Disks (continued)Access 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)
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)
brNbrN
Access Performance of Disks (continued)Access Performance of Disks (continued)
The average access time, Ta is:
Ta = Ts + + (4)
The average access time, Ta is:
Ta = Ts + + (4)12r
br N
Disk Scheduling PoliciesDisk Scheduling Policies
In practice disk access times are highly
sensitive to the previous head position.
Most disk scheduling algorithms focus
on this.
In practice disk access times are highly
sensitive to the previous head position.
Most disk scheduling algorithms focus
on this.
0
100
125
150
175
25
50
199
75
(a) FIFOTime
Some Disk SchedulesSome Disk Schedules
0
100
125
150
175
25
50
199
75
(b) SSTFTime
0
100
125
150
175
25
50
199
75
(c) SCANTime
0
100
125
150
175
25
50
199
75
(d) C-SCANTime
Disk Free Space ManagementDisk 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
Available space needs to be found
quickly for storage. Typically blocks are:
1. Corrupted --- Hardware failure, not
available for use
2. Free
3. Used
Disk Free Management (continued)Disk Free Management (continued)
Typically either bitmaps are used, or alist 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.
Typically either bitmaps are used, or alist 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.
Disk Block Allocation MethodsDisk Block Allocation Methods
1. Contiguous
2. Linked List (and FAT)
3. Indexed
1. Contiguous
2. Linked List (and FAT)
3. Indexed
Contiguous AllocationContiguous Allocation
This requires that a file n blocks long
occupy n contiguous blocks. External
fragmentation and file placement are
difficult problems.
This requires that a file n blocks long
occupy n contiguous blocks. External
fragmentation and file placement are
difficult problems.
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31 list
count
directoryFile
Count tr mail list f
Start
0 14 19 28 6
Length
2 3 6 4 2
A Contiguous Allocation Scheme
A Contiguous Allocation Scheme
Linked AllocationLinked 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.
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.
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
28 29 30 31
directory
File Start End
Jeep 9 25
A Linked Allocation Scheme A Linked Allocation Scheme
10
16
25
1
-1
key
File Allocation tablesFile 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.
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.
File Allocation TableFile Allocation TableScheme (FAT)Scheme (FAT)
test 217name
Directory entry
. . .Start block
618
End-of-file
339
No. of disk blocks -1
618
339
217
0
FAT
Indexed SchemesIndexed Schemes
Each file has an index block which is anarray 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
Each file has an index block which is anarray 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
Unix File System LayoutUnix 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.
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.
Unix File system PartitionsUnix File system Partitions
partition partition partitionDisk drive
i-node i-node i-node. . .
i-listDirectory blocks and
data blocksfile-system
boot block(s)
super block
17.6 - Unix INODE Usage17.6 - Unix INODE UsageThe INODES form a Btree of the blocks in a file.
i-listdatalock
datalock
directoryblock
datalock
directoryblock
directory blocks and data blocks
i-node i-nodei-node i-nodefilenamei-node #
filenamei-node #2nd data block3rd data block
1st data block
Unix INODE UsageUnix INODE Usage
Directory blocks contain Inodeinformation for files in the directory. TheUnix file system is a directed rooted graph (but not a tree or DAG). Partitionscan be added by mounting them (i.e.inserting them into the directory structure). MS-DOS does not havemounting.
Directory blocks contain Inodeinformation for files in the directory. TheUnix file system is a directed rooted graph (but not a tree or DAG). Partitionscan be added by mounting them (i.e.inserting them into the directory structure). MS-DOS does not havemounting.
Figure 14: Inodes and directories inFigure 14: Inodes and directories inthe Unix file systemthe Unix file system
i-listdirectory
blockdirectory
block
directory blocks and data blocks
i-node0
i-node1267
i-node2549
2549
1267
.
. .
1267i-node
#. .
.
2549 testdir
data block