Title: Dear All,
1Dear All, 1 Remember to bring in the notes that
we have not completed on week 9. And we will
continue on 26th (Monday) from where we
stopped. 2 This notes for week 10 is the Part
2 continuation. 3 The tutorial document
consists of 2 weeks of tutorial material for week
10 and week 11 contact hour, respectively. 4
Next in line is the Week 11(Storage Files).
Week 12(Multiprocessing) and Week
13(Revision).
2 Week 09 19/March/2007
Week 10 26/March/2007
- I/O and low level support (part 2 of 2)
3Input Class
Random Access
Mouse, cursor key, numeric key pad
Block Device
4Harddisk as a Block device
5Block versus Stream I/O
- Block-oriented
- Information is stored in fixed sized blocks
- Transfers are made a block at a time
- Used for disks and tapes
- Stream-oriented
- Transfer information as a stream of bytes
- Used for terminals, printers, communication
ports, mouse and other pointing devices, and most
other devices that are not secondary storage
6I/O Buffering
- Reasons for buffering
- Processes must wait for I/O to complete before
proceeding - Certain pages must remain in main memory during
I/O
7Single Buffer
- Operating system assigns a buffer in main memory
for an I/O request - Block-oriented
- Input transfers made to buffer
- Block moved to user space when needed
- Another block is moved into the buffer
- Read ahead
8Single Buffer
- Stream-oriented
- Used a line at time
- User input from a terminal is one line at a time
with carriage return signaling the end of the
line - Output to the terminal is one line at a time
9I/O Buffering
10Double Buffer
- Use two system buffers instead of one
- A process can transfer data to or from one buffer
while the operating system empties or fills the
other buffer
11Circular Buffer
- More than two buffers are used
- Each individual buffer is one unit in a circular
buffer - Used when I/O operation must keep up with process
12Harddisk as a Block device
13Disk Structure
- Disk drives are addressed as large 1-dimensional
arrays of logical blocks - The logical block is the smallest unit of
transfer. - The 1-dimensional array of logical blocks is
mapped into the sectors of the disk sequentially - Sector 0 is the first sector of the first track
on the outermost cylinder. - Mapping proceeds in order through that track,
then the rest of the tracks in that cylinder, and
then through the rest of the cylinders from
outermost to innermost.
14I/O Architecture
- Host accessed storage through I/O ports talking
to I/O buses - SCSI is a I/O bus with up to 16 devices per cable
- SCSI initiator requests operation and SCSI
targets perform tasks - Each target can have up to 8 logical units
(disks attached to device controller)
15Disk Types
- Disks can be removable
- Drive attached to computer via I/O bus
- Variations include EIDE, ATA, SATA, USB, SCSI
- Host controller in computer uses bus to talk to
disk controller built into drive or storage array
16Disk Performance Parameters
- To read or write, the disk head must be
positioned at the desired track and at the
beginning of the desired sector - Seek time
- Time it takes to position the head at the desired
track - Rotational delay or rotational latency
- Time its takes for the beginning of the sector
to reach the head
17Timing of a Disk I/O Transfer
18Disk Performance Parameters
- Access time
- Sum of seek time and rotational delay
- The time it takes to get in position to read or
write - Data transfer occurs as the sector moves under
the head
19Transfer Time for one sector
- The transfer time from disk
- T (b/rN)
- where
- b number of bytes to be transferred
- N number of bytes on a track
- r rotation speed (rev./sec)
- The average access time
- Ta T_seek (1/2r) (b/rN)
20Disk Scheduling Policies
- Seek time is the reason for differences in
performance - For a single disk there will be a number of I/O
requests - If requests are selected randomly, we will poor
performance
21Disk Scheduling Policies
- Priority
- Goal is not to optimize disk use but to meet
other objectives - Short batch jobs may have higher priority
- Provide good interactive response time
22Disk Scheduling Policies
- Last-in, first-out
- Good for transaction processing systems
- The device is given to the most recent user so
there should be little arm movement - Possibility of starvation since a job may never
regain the head of the line
23Disk Scheduling Policies
- For a disk, a queue of I/O requests (Read/ Write)
for processes - Random scheduling
- Selected requests in random, tracks visited will
occur randomly giving poor performance - Use as benchmark for evaluating other scheduling
techniques - To improve performance, one needs to reduce
average time spent on seeks
24Disk Scheduling Policies
- First-in, first-out (FIFO)
- Process request sequentially
- Fair to all processes
- Approaches random scheduling in performance if
there are many processes - Requests sequence 55,58,39,18,90,160, 150,38,184
25Disk Scheduling Policies
- Shortest Service Time First
- Select the disk I/O request that requires the
least movement of the disk arm from its current
position - Always choose the minimum Seek time
26Disk Scheduling Policies
- SCAN
- Arm moves in one direction only, satisfying all
outstanding requests until it reaches the last
track in that direction - Direction is reversed
27Disk Scheduling Policies
- C-SCAN
- Restricts scanning to one direction only
- When the last track has been visited in one
direction, the arm is returned to the opposite
end of the disk and the scan begins again
28Disk sectors are typically cached for subsequent
update before finally committing and write back
to sector
29Least Frequently Used Caching
- The block that has experienced the fewest
references is replaced - A counter is associated with each block
- Counter is incremented each time block accessed
- Block with smallest count is selected for
replacement - Some blocks may be referenced many times in a
short period of time and the reference count is
misleading
30(No Transcript)
31(No Transcript)
32Linux I/O
- Elevator scheduler
- Maintains a single queue for disk read/write
requests - Keeps list of requests sorted by block number
- Drive moves in a single direction to satisfy each
request
33Linux I/O
- Deadline scheduler
- Uses three queues
- Incoming requests
- Read requests go to the tail of a FIFO queue
- Write requests go to the tail of a FIFO queue
- Each request has an expiration time
34Linux I/O
35Windows I/O
- Basic I/O modules
- Cache manager
- File system drivers
- Network drivers
- Hardware device drivers
36Low Level I/O support consideration
37From Lecture on Threads
38Microkernel Design from threads lecture
- Low-level memory management
- Mapping each virtual page to a physical page
frame - 2pages example
- Interprocess communication
- 2 pages example
- I/O and interrupt management
- 3 pages example
39NS Cache Management embedded in Processor
40MC68000 on chip Error Handling
41Lightweight Interprocess Structure
42NS on chip support for Interprocess
43MC68000 on chip DMA interfacing
44MC68000 Comprehensive Interrupt Structure
45Small System Implementation with auto-vector
interrupt via VPA low
End of week 10 Lecture