You are on page 1of 67

Môn: Kiến trúc máy tính & HĐH

Chapter 7

INPUT/OUTPUT

Trình bày: Lê Thành Trung


Input/Output

7.1 EXTERNAL DEVICES


 Keyboard/Monitor
 Disk Drive
7.2 I/O MODULES
 Module Function
 I/O Mudule Structure
Input/Output
Input/Output

This module has two major functions


(Figure 7.1):
Interface to the processor and
memory via the system bus or
central switch
Interface to one or more peripheral
devices by tailored data links
Internal Devices

We can broadly classify into three


categories:
Human readable: communication
with the computer user
Machine readable: communication
with equipment
Communication: communication
with remote devices
Internal Devices
Keyboard/Monitor

• The user depressed a key from the


keyboard
• Data is displayed on the monitor
Keyboard/Monitor
Disk Drive

• For changing data, control and status


signal with an I/O module
• The transducer is capable of converting
between the magnetic patterns on the
moving disk surface and bits in the
device’s buffer

9
I/O module

Module function:
Control and timing
Processor communication
Device communication
Data buffering
Error detection
I/O module
Module function
The transfer of data from an external device
to the processor:
The processor interrogates the I/O module to
check the status of the attached device
The I/O module return the device status
If the device is operational and ready
transmit, the processor requests the transfer of
data
The I/O module obtains a unit of data from
the external device
The data are transferred from the I/O module
Module function

Processor communication:
Command decoding
Data
Status reporting
Address recognition
Module function

Device communication:
Command
Status information
Data
Module function

Data buffering (hình 7.3):


The data are buffered in the I/O
module and then sent to the
peripheral device at its data rate
If the I/O module operates at a rate
higher than the memory acess rate,
then the I/O module perform the
needed buffering operation
Module function

Error detection:
For error detection and sent
reporting errors to the processor
Mechanical and electrical
malfunctions
Using a parity bit
I/O Module Structure
Nhóm ba
7.3 &7.4
Trình bày
ĐẶNG HOÀI SINH
Nội dung bài báo cáo gồm:
Bốn kĩ thuật dùng để điều khiển hoạt động
I/O.
1. Lập trình điều khiển I/O
2. Điều khiển ngắt I/O
3.DMA(Truy cập bộ nhớ trực tiếp)
4.Channel I/O
Ở đây chỉ đi sâu vào hai kĩ thuật 1,2.Kĩ
thuật thứ 3,4 do bạn Trần Đức Minh báo
cáo rõ hơn với các bạn.
Vị trí của I/O trong máy tính
Cấu trúc của một khối I/O
Lập trình điều khiển I/O
 Programmed I/O dùng để trao đổi dữ liệu giữa
bộ xử lý và I/O.
 Bộ xử lý thực thi một chương trình dùng để điều
khiển trực tiếp hoạt động I/O.
 Chương trình này bao gồm:
- Thăm dò trạng thái thiết bị
- Gửi một lệnh đọc hoặc ghi
- Quá trình truyền dữ liệu
Lập trình điều khiển I/O
 Khi bộ xử lý đang thực thi một chương trình và
gặp một tập lệnh liên quan đến I/O,nó thực thi
tập lệnh đó bằng cách phát ra một lệnh và một
địa chỉ đến khối I/O đó.
 Và khối I/O này thực thi hoạt động mong muốn
 Trước khi thực thi hoạt động của mình khối I/O
phải thiết lập những bít tương đương lên thanh
ghi trạng thái.
Lập trình điều khiển I/O
 Lúc này I/O không ngắt và không gửi cảnh
báo nào đến bộ xử lý.
 Và bộ xử lý chỉ có nhiệm vụ giám sát trạng
thái của thiết bị I/O cho tới khi nó biết rằng
hoạt động I/O đã được kết thúc.
 Kĩ thuật Programmed I/O hoạt động như thế
nào chúng ta hãy tìm hiểu tập lệnh mà CPU
gửi đến I/O.
Có 4 loại lệnh I/O mà khối I/O có
thể nhận được từ CPU.
 Điều khiển:Kích hoạt và yêu cầu công việc cho
thiết bị ngoại vi.
 Kiểm tra:Kiểm tra những điều kiện thay đổi trạng
thái thiết bị ngoại vi,cho biết thiết bị nào được
CPU phục vụ và giám sát lỗi hoạt động I/O.
 Đọc:Đọc dữ liệu từ thiết bị ngoại vi và lưu vào
bộ đệm nội.
 Ghi: gửi mẫu dữ liệu(byte hoặc word)từ bus dữ
liệu và trình tự truyền mẫu dữ liệu đến thiết bị
ngoại vi
Tập lệnh của I/O gửi đến CPU
 Tập lệnh liên quan đến I/O mà bộ xử lý lấy ra từ bộ
nhớ thường dễ được ánh xạ vào bộ lệnh dùng để
thực thi tập lệnh liên quan đến I/O của bộ xử lý.
 Thường có nhiều thiết bị I/O kết nối đến khối
I/O.Mỗi thiết bị này được nhận dạng bằng một địa
chỉ duy nhất.Khi bộ xử lý phát ra một lệnh,lệnh
này chứa địa chỉ thiết bị I/O mong muốn.
 Do đó mỗi khối I/O phải hiểu được đường địa chỉ
này để xác định nếu lệnh là của chính nó.
Tập lệnh của I/O gửi đến CPU
 Khi CPU,I/O,memory dùng chung một bus
hai chế độ địa chỉ có thể diễn ra:
 Memory mapped I/O
 Isolated I/O
Điều khiển ngắt
 Vấn đề programmed I/O yêu cầu bộ xử lý phải
đợi một thời gian dài đến khi nào thiết bị I/O
nhận hoặc truyền dữ liệu và trong thời gian này
bộ xử lý phải giám sát hoạt động của I/O
 Điều đó làm cho hiệu suất sử dụng của toàn hệ
thống không hiệu quả.
 Để khắc phục hạn chế này chúng ta hãy tìm
hiểu kĩ thuật điều khiển ngắt I/O.
Điều khiển ngắt:
 Thay vì bộ xử lý đợi giám sát quá trình thực
thi cho tới khi thiết bị I/O kết thúc.Lúc này nó
gửi một lệnh đến thiết bị I/O và sau đó tiếp tục
làm những công việc hữu ích khác.Sau đó
thiết bị I/O sẽ ngắt bộ xử lý để yêu cầu dịch vụ
nếu như nó sẵn sàng trao đổi dữ liệu với bộ xử
lý.Sau đó bộ xử lý thực thi quá trình truyền dữ
liệu,sau đó mới trở lại xử lý chương trình cũ.
Tiến trình điều khiển ngắt I/O
Sự trao đổi giữa bộ nhớ và thanh
ghi trong tiến trình ngắt
Giải thuật dùng programmed và Interrupt
I/O để đọc khối dữ liệu từ một thiết bị
ngoại vi
 Phần báo cáo của tôi đến đây kết
thúc
 Cảm ơn các bạn đã quan tâm theo

dõi
Nhoùm 3: Input/Output. Lôùp
D02VTA1
7.5. TRUY NHAÄP BOÄ NHÔÙ
TRÖÏC TIEÁP
DIRECT MEMORY ACCESS(
DMA)

Sinh vieân: Traàn Ñöùc Minh


MSV: 402160022
7.5. DIRECT MEMORY ACCESS( DMA)

Haïn cheá cuûa Programmed vaø


Interrupt-Driven
I/O:
- Toác ñoä truyeàn I/O bò giôùi haïn bôûi
toác ñoä CPU.
- CPU bò raøng buoäc vaøo vieäc quaûn
lyù truyeàn I/O.
Khi 1 khoái löôïng data lôùn ñöôïc di
chuyeån thì
caàn 1kó thuaät hieäu quaû hôn, ñoù laø
DMA.
7.5. DIRECT MEMORY ACCESS( DMA)
Chöùc naêng cuûa DMA:

 DMA coù theâm 1 module treân system


bus.
Module naøy coù khaû naêng nhö 1 boä xöû
lyù vaø coù
theå tieáp quaûn vieäc ñieàu khieån töø
CPU, cho
pheùp trao ñoåi data vôùi memory qua
system
bus.
 DMA module söû duïng 1 ñöôøng bus maø
CPU
khoâng duøng, hoaëc laø baét buoäc CPU
7.5. DIRECT MEMORY ACCESS( DMA)

Kó thuaät Cycle stealing :


Khi CPU muoán ñoïc hay ghi 1 block döõ
lieäu, noù ñöa
ra1 leänh cho DMA_module vôùi caùc thoâng
tin sau:
 Yeâu caàu read or write, söû duïng control line.
 Ñòa chæ cuûa caùc thieát bò I/O lieân quan, söû
duïng data lines.
 Vò trí baét ñaàu read or write trong memory,
thoâng tin naøy truyeàn treân data lines vaø ñöôïc
löu laïi trong address_register cuûa DMA module.
 Soá löôïng words ñöôïc ñoïc hoaëc ghi, truyeàn
treân data lines vaø ñöôïc löu trong thanh ghi
7.5. DIRECT MEMORY ACCESS( DMA)
7.5. DIRECT MEMORY ACCESS( DMA)

Kó thuaät Cycle stealing :


Sau ñoù:
• CPU uyû nhieäm cho DMA_module thöïc hieän
caùc hoaït ñoäng I/O.
• DMA_module seõ truyeàn daãn toaøn boä block
döõ lieäu, moãi laàn 1 word, tröïc tieáp vôùi
memory maø khoâng caàn qua CPU.
Ñeå coù theå truy nhaäp tröïc tieáp vaøo memory,
DMA_module seõ
cöôùp 1 chu kì laøm vieäc cuûa CPU treân
system_bus. Ñieàu
naøy coù theå laøm cho CPU hoaït ñoäng chaäm
hôn.
Tuy nhieân, ñeå truyeàn daãn I/O vôùi nhieàu word
7.5. DIRECT MEMORY ACCESS( DMA)

• Khi hoaït
ñoängtruyeàn daãn
hoaøn thaønh,
DMA_ module göûi
1 tín hieäu ngaét
ñeán CPU.
• Nhö vaäy, CPU chæ
lieân quan tôùi
luùc baét ñaàu vaø
keát thuùc vieäc
truyeàn daãn.
Caùc caáu hình cuûa heä thoáng
DMA:
7.6 CHANNELS and PROCESSORS
I/O:
Caùc böôùc phaùt trieån cuûa chöùc
naêng I/O:
1. CPU tröïc tieáp ñieàu khieån thieát bò
ngoaïi vi.
2. I/O module ñöôïc theâm vaøo. CPU söû
duïng
Programmed I/O maø khoâng coù
interrupt. Vôùi
böôùc naøy, CPU trôû neân taùch bieät
vôùi caùc thieát bò
giao tieáp beân ngoaøi.
3. Töông töï nhö böôùc 2, nhöng coù söû
7.6 CHANNELS AND PROCESSORS
I/O:
Caùc böôùc phaùt trieån cuûa chöùc
naêng I/O:
4. I/O module truy nhaäp tröïc tieáp vaøo
boä nhôù thoâng qua DMA, khoâng coù
söï can thieäp cuûa CPU, ngoaïi tröø luùc
baét ñaàu vaø luùc keát thuùc vieäc
truyeàn daãn.
5. I/O module ñöôïc naâng caáp trôû thaønh
1 processor. CPU ra leänh cho
I/O_processor tìm vaø thi haønh 1 chöông
trình I/O trong boä nhôù, khoâng coù söï
can thieäp cuûa CPU .
6. I/O module coù 1 local_memory vaø nhö 1
7.6 CHANNELS AND PROCESSORS
I/O:
Caùc böôùc phaùt trieån cuûa chöùc
naêng I/O:
 Nhö vaäy, doïc theo con ñöôøng phaùt
trieån, ngaøy caøng coù nhieàu chöùc
naêng I/O ñöôïc thöïc hieän maø khoâng
coù söï can thieäp cuûa CPU. CPU ñöôïc
giaûm nheï nhieäm vuï lieân quan ñeán
I/O.
 Hai böôùc sau cuøng(5,6) laø moät thay
ñoåi lôùn khôûi ñaàu cho khaùi nieäm
moät I/O_module coù khaû naêng thi
haønh 1 chöông trình. Trong böôùc 5, I/O
module ñöôïc xem laø 1 I/O channel.
7.6 CHANNELS AND PROCESSORS
I/O:
Caùc ñaëc ñieåm cuûa I/O channel:
 I/O channel laø moät söï môû roäng cuûa
khaùi nieäm DMA, trong ñoù, I/O_module
ñöôïc naâng caáp nhö 1 processor.
 Moät I/O channel coù khaû naêng:
- Tìm vaø thi haønh caùc chæ thò I/O
ñöôïc löu trong main memory.
- Ñieàu khieån hoaøn toaøn caùc hoaït
ñoäng I/O.
7.6 CHANNELS AND PROCESSORS
I/O:
I/O channel:
 CPU chæ khôûi ñaàu 1 I/O transfer baèng
caùch ra leänh cho I/O channel thi haønh 1
chöông trình trong boä nhôù.
 Chöông trình seõ chæ roõ:

- Caùc thieát bò
- Caùc vuøng boä nhôù
ñeå löu tröõ
- Quyeàn öu tieân
- Caùc hoaït ñoäng
nhaèm ñöa ra caùc ñieàu kieän coù sai
soá nhoû nhaát.
 I/O channel seõ döïa theo caùc chæ daãn
7.6 CHANNELS AND PROCESSORS
I/O:
Coù 2 loaïi I/O channel phoå bieán:
1. Selector- channel:
- Ñieàu khieån nhieàu thieát bò toác ñoä
cao, nhöng taïi 1 thôøi ñieåm noù chæ
truyeàn data vôùi 1 thieát bò.
- Moãi thieát bò (hoaëc 1 nhoùm nhoû
caùc thieát bò) ñöôïc ñieàu khieån bôûi 1
I/O_controller.
7.6 CHANNELS AND PROCESSORS
I/O:

2. Multiplexor_channel:
- Coù theå ñieàu khieån nhieàu thieát bò cuøng
luùc.
- Moät boä ña hôïp seõ gheùp caùc block döõ
lieäu cuûa nhieàu thieát bò laïi vôùi nhau.
- Vôùi caùc thieát bò toác ñoä thaáp, 1 boä gheùp
byte seõ giuùp chuyeån ñoåi cho phuø hôïp vôùi
caùc thieát bò toác ñoä cao.
VD:
caùc chuoãi kí töï rieâng leû cuûa 3 thieát bò
coù toác ñoä khaùc nhau A1A2A3A4 ……
B1B2B3B4 …… C1C2C3C4 seõ trôû thaønh
A1B1C1A2C2A3B2C3A4 ……
7.6 CHANNELS AND PROCESSORS
I/O:
 Kieán truùc Multiplexor_channel:
External Interface

FireWire & InfiniBand

Presented by Lâm Phan Nhật Nam


IEEE 1394 FireWire
 High performance serial bus
 Fast
 Low cost
 Easy to implement
 Also being used in digital cameras,
VCRs and TV
FireWire Configuration
 Daisy chain
 Up to 63 devices on single port
 Really 64 of which one is the interface
itself
 Up to 1022 buses can be
connected with bridges
 Automatic configuration
 No bus terminators
 May be tree structure
Simple FireWire
Configuration
FireWire 3 Layer Stack
 Physical
 Transmission medium, electrical and
signaling characteristics
 Link
 Transmission of data in packets
 Transaction
 Request-response protocol
FireWire Protocol Stack
FireWire - Physical Layer
 Data rates from 25 to 400Mbps
 Two forms of arbitration
 Based on tree structure
 Root acts as arbiter
 First come first served
 Natural priority controls simultaneous
requests
 i.e. who is nearest to root
 Fair arbitration
 Urgent arbitration
FireWire - Link Layer
 Two transmission types
 Asynchronous
 Variable amount of data and several
bytes of transaction data transferred as a
packet
 To explicit address
 Acknowledgement returned
 Isochronous

Variable amount of data in sequence of
fixed size packets at regular intervals
 Simplified addressing
FireWire Subactions
InfiniBand
 I/O specification aimed at high end
servers
 Merger of Future I/O (Cisco, HP,
Compaq, IBM) and Next Generation
I/O (Intel)
 Version 1 released early 2001
 Architecture and specifications for
data flow between processor and
intelligent I/O devices
InfiniBand(cont)
 Intended to replace PCI in servers
 Increased capacity, expandability,
flexibility
InfiniBand Architecture
 Remote storage, networking and
connection between servers
 Attach servers, remote storage,
network devices to central fabric of
switches and links
 Greater server density
InfiniBand
Architecture(cont)
 Scalable data centre
 Independent nodes added as
required
 I/O distance from server up to
 17m using copper
 300m multimode fibre optic
 10km single mode fibre
 Up to 30Gbps
InfiniBand Switch Fabric
InfiniBand Operation
 16 logical channels (virtual lanes)
per physical link
 One lane for management, rest for
data
 Data in stream of packets
 Virtual lane dedicated temporarily
to end to end transfer
 Switch maps traffic from incoming
to outgoing lane
InfiniBand Protocol Stack
Foreground Reading
 Check out Universal Serial Bus
(USB)
 Compare with other
communication standards e.g.
Ethernet

You might also like