0% found this document useful (0 votes)
9 views

Chapter 05 OS - Ver1.1

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Chapter 05 OS - Ver1.1

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 72

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 I/O devices: Disks,
Character-oriented terminals,
Clocks

1
5.1 Principles of I/O hardware

2
Principles of I/O Hardware
Types of I/O devices

Two main groups: Block and Character Devices


• Block devices include disk drives
– Commands include read, write, seek
– Raw I/O or file-system access
– Memory-mapped file access possible
• Character devices include keyboards, mice, serial ports
– Commands include get, put
– Libraries layered on top allow line editing

3
Principles of I/O Hardware
Types of I/O devices
Some typical device, network, and data base rates

4
Principles of I/O Hardware
Common concepts

Common concepts
– I/O Device Controller
– I/O Port
– I/O Bus

5
Principles of I/O Hardware
Device Controllers
Monitor

Bus

• Components of a simple personal computer


6
Principles of I/O Hardware
Device Controllers
• I/O devices have components:
– electromechanical component
– electronic component
• The electronic component is the device
controller
– may be able to handle multiple devices
• Controller's tasks (Disk)
– convert serial bit stream to block of bytes
– perform error correction as necessary
– make available to main memory
7
Principles of I/O Hardware
I/O Port

I/O Port is a register in device interface. Example: Device I/O Port


Locations on PCs (partial)

8
Principles of I/O Hardware
A Typical PC Bus Structure

9
Principles of I/O Hardware
I/O address

• I/O instructions control devices


• Devices have addresses, used by
– Direct I/O instructions
– Memory-mapped I/O

10
Principles of I/O Hardware
Memory-Mapped I/O (1)

• Separate I/O and memory space


• Memory-mapped I/O
• Hybrid
11
Principles of I/O Hardware
Memory-Mapped I/O (2)

(a) A single-bus architecture


(b) A dual-bus memory architecture
12
Principles of I/O Hardware
Data transfer Method between CPU and I/O device

Three Data I/O transfer Methods:


• Programmed I/O
• Interrupt-Driven I/O
• Direct Memory Access

13
Principles of I/O Hardware
Programmed I/O, Polling

• Determines state of device


– ready
– busy
– Error
• Busy-wait cycle to wait for I/O from device

14
Principles of I/O Hardware
Interrupt-Driven I/O

How interrupts happens. Connections between devices and interrupt controller


actually use interrupt lines on the bus rather than dedicated wires

15
Principles of I/O Hardware
Example: Interrupts of PC computer

16
Principles of I/O Hardware
Direct Memory Access (DMA)

Operation of a DMA transfer


17
Principles of I/O Hardware
Example: DMA Transfer in PC Computer

18
5.2 Principles of I/O software

19
Principles of I/O Software
Goals of I/O Software (1)
• Device independence
– programs can access any I/O device
– without specifying device in advance
(floppy, hard drive, or CD-ROM)
• Uniform naming
– name of a file or device is a string or an integer
– not depending on which machine
• Error handling
– handle as close to the hardware as possible

20
Principles of I/O Software
Goals of I/O Software (2)
• Synchronous vs. asynchronous transfers
– blocked transfers vs. interrupt-driven
• Buffering
– data coming off a device cannot be stored in
final destination
• Sharable vs. dedicated devices
– disks are sharable
– tape drives would not be

21
Principles of I/O Software
Programmed I/O (1)

Steps in printing a string


22
Principles of I/O Software
Programmed I/O (2)

Writing a string to the printer using


programmed I/O
23
Principles of I/O Software
Interrupt-Driven I/O

• Writing a string to the printer using interrupt-driven I/O


– Code executed when print system call is made
– Interrupt service procedure
24
Principles of I/O Software
I/O Using DMA

• Printing a string using DMA


– code executed when the print system call is made
– interrupt service procedure

25
A Kernel I/O Structure:
Hardware And Software

26
5.3 I/O software layers

27
I/O Software Layers

Layers of the I/O Software System

28
I/O Software Layers
Interrupt Handlers (1)
• Interrupt handlers are best hidden
– have driver starting an I/O operation block until
interrupt notifies of completion
• Interrupt procedure does its task
– then unblocks driver that started it
• Steps must be performed in software after interrupt
completed
1. Save regs not already saved by interrupt hardware
2. Set up context for interrupt service procedure

29
I/O Software Layers
Interrupt Handlers (2)
3. Set up stack for interrupt service procedure
4. Ack interrupt controller, reenable interrupts
5. Copy registers from where saved to process
table
6. Run service procedure
7. Set up MMU context for process to run next
8. Load new process' registers
9. Start running the new process

30
I/O Software Layers
Device Drivers

• Logical position of device drivers is shown here


• Communications between drivers and device controllers goes
over the bus
31
I/O Software Layers
Device-Independent I/O Software (1)

Uniform interfacing for device drivers


Buffering
Error reporting
Allocating and releasing dedicate devices
Providing a device-independent block
size

Functions of the device-independent I/O software


32
I/O Software Layers
Device-Independent I/O Software (2)

(a) Without a standard driver interface


(b) With a standard driver interface
33
I/O Software Layers
Device-Independent I/O Software (3)

(a) Unbuffered input


(b) Buffering in user space
(c) Buffering in the kernel followed by copying to user space
(d) Double buffering in the kernel

34
I/O Software Layers
Device-Independent I/O Software (4)

Networking may involve many copies


35
User-Space I/O Software

Layers of the I/O system and the main functions of each layer

36
5.4 I/O devices

37
I/O devices

• Storage devices: Hard Disks, CD-ROM,


CD-R, DVD…
• Display devices: Character-oriented
terminals, Graphical user interfaces
• Clocks

38
Hard Disk Drive

39
Disk Hardware (2)

40
41
42
43
44
45
46
Disk Performance Parameters

• To read or write, disk head must be positioned


at desired track and at beginning of desired
sector
• Read/write time factors:
1. Seek time: time it takes to position the head at
desired track
2. Rotational delay or rotational latency: time its
takes for beginning of sector to reach head
3. Actual data transfer time

47
Timing of a Disk I/O Transfer

48
Disk Performance Parameters
• Transfer time
– data transfer occurs as the disk moves under head
– depends on rotational speed of disk

Tt=b/rN
Tt = transfer time
b = no of bytes to transfer
N = no of bytes on a track
r = rotational speed (rps)

49
HDD Access Time
• Sum of seek time, rotational delay and transfer time

Ta = T s + T r + T t
• Average seek time  Ts
• Time for half a revolution  Tr

Ta = Ts + 0.5/r + b/rN
assuming that all data to be read is on the same track, i.e.
no head re-positioning is required

50
Disk Scheduling Algorithms

• For a single disk there will be a number of I/O


requests

• If requests are selected randomly we will get the


worst possible performance
– seek time will dominate

• FCFS will not be entirely random due to locality

51
Disk Scheduling Algorithms

52
Disk Scheduling Algorithms
First In First Out (FIFO)
• simplest form of scheduling

• Each request processed in arrival order

• Advantages
– simple and fair
– no starvation
• unless a single request is extremely long.

• Disadvantages
– stupid and slow.

53
Disk Scheduling Algorithms
Shortest Seek Time First (SSTF)
• Request causing least disk arm movement selected
– a priority based policy

• Advantages
– Performs better than FIFO
– offers "locality" -- benefits disk operations close together

• Disadvantages
– can cause starvation during high request rate
– No guarantee that average seek time will be minimum over
time

54
Shortest Seek Time First (SSTF)

55
SCAN (elevator algorithm)
and is moving toward cylinder 0

56
RAID (1)

• Raid levels 0 through 2


• Backup and parity drives are shaded
57
RAID (2)

• Raid levels 3 through 5


• Backup and parity drives are shaded
58
59
60
61
62
63
Display Hardware (1)

Parallel port

Memory-mapped displays
• driver writes directly into display's video RAM

64
Display Hardware (2)

65
Display Hardware (3)

66
Character Oriented Terminals
RS-232 Terminal Hardware

• An RS-232 terminal communicates with computer 1 bit at a time


• Called a serial line – bits go out in series, 1 bit at a time
• Windows uses COM1 and COM2 ports, first to serial lines
• Computer and terminal are completely independent
67
Clocks
Clock Hardware

A programmable clock
68
69
• Cấu trúc đĩa CD, DVD: chia vùng ntnao?
Lưu trữ dữ liệu theo kiểu gì?
• DVD khác CD ở điểm nào mà dung lượng
nhiều hơn?

• HDD, SSD.

70
• Tìm 3 nhà sản xuất đĩa cứng HDD. Thị phần và khuyến cáo lợi thế, bất lợi của
sản phẩm từng công ty.
Western Digital (43%), Segate (41%), Toshiba (16%)…
SATA, ATA, SCSI, EIDE…
16MB, 8MB…
FAT32, NTFS, ext2-3, …
3.5inch, 1.8, 2.5, …
• Xem các thông số của 1 ổ đĩa cứng, giải thích ý nghĩa của từng thông số: tốc độ
quay, giao tiếp, bộ nhớ đệm, dung lượng, kích thước…
• Trình bày cấu trúc vật lý của ổ đĩa cứng: track, sector, cylinder, trục quay, đầu
đọc/ghi…
• Các định dạng phân vùng dùng được cho HDD

71
• List 3 HDD manufactures, their market shares, the advantages and
disadvantages of each one?
• List all factors of HDD, explain the meaning of each one, such as:
rotation speed, interface, buffer, capacity, size,…
• Xem các thông số của 1 ổ đĩa cứng, giải thích ý nghĩa của từng thông
số: tốc độ quay, giao tiếp, bộ nhớ đệm, dung lượng, kích thước…
• Trình bày cấu trúc vật lý của ổ đĩa cứng: track, sector, cylinder, trục
quay, đầu đọc/ghi…
• Các định dạng phân vùng dùng được cho HDD

72

You might also like