Anda di halaman 1dari 14

Direct Memory Access

Hari Wibawanto
Arsitektur Komputer
Organisasi dan Arsitektur Komputer
PTIK FT Universitas Negeri Semarang
Review Modul Input/Output
Gambar di samping menunjukkan diagram
blok komponen-komponen yang
membentuk modul I/O. Modul I/O
bertanggungjawab untuk memindahkan
data antara memori utama dan
antarmuka perangkat tertentu.
Antarmuka atau interface itu dirancang
khusus untuk berkomunikasi dengan
perangkat tertentu, misalnya keyboard,
disk, atau printer. Interface akan
mengambil alih detil operasi dan
memastikan perangkat siap menerima
atau mengirim data dari dan ke sistem
prosesor..
• Bentuk dan arti yang tepat dari sinyal yang dipertukarkan antara
pengirim dan penerima (prosesor dan modul I/O, dan sebaliknya)
disebut protokol. Protokol mencakup sinyal perintah, misalnya
"Reset printer"; sinyal status, misalnya “Disk siap”; atau sinyal
penerusan data, misalnya pesan "Ini byte yang Anda minta“. Pada
sebagian besar protokol pertukaran data, penerima harus
mengetahui perintah dan data yang dikirim kepadanya atau
menunjukkan bahwa ia siap menerima data. Jenis pertukaran
protokol ini disebut sebagai “handshake” atau jabat tangan.
• Perangkat eksternal yang menangani blok data yang besar
(misalnya printer, disk drive atau SSD) sering kali dilengkapi
dengan memori buffer. Buffer memungkinkan sistem host
mengirimkan data dalam jumlah besar ke perangkat periferal
secepat mungkin, tanpa harus menunggu hingga perangkat
mekanis yang lambat benar-benar mengirimkan data. Memori
khusus pada disk drive biasanya memiliki jenis cache yang cepat,
sedangkan printer biasanya dilengkapi dengan RAM yang lebih
lambat.
I/O Control Methods

• Because of the great differences in control methods and transmission modes among various kinds of I/O
devices, it is infeasible to try to connect them directly to the system bus. Instead, dedicated I/O modules
serve as interfaces between the CPU and its peripherals.
• These modules perform many functions, including controlling device actions, buffering data, performing error
detection, and communicating with the CPU. In this section, we are most interested in the method by which
these I/O modules communicate with the CPU, thus controlling I/O.
• Computer systems employ any of five general I/O control methods:
 programmed I/O,
 interrupt-driven I/O,
 memory-mapped I/O,
 direct memory access, and
 channel-attached I/O.
• Although one method isn’t necessarily better than another, the manner in which a computer controls its I/O
greatly influences overall system design and performance. The objective is to know when the I/O method
employed by a particular computer architecture is appropriate to how that system will be used
Programmed I/O

• Cara termudah bagi CPU untuk berkomunikasi dengan perangkat I/O adalah melalui I/O terprogram, terkadang
disebut I/O yang disurvei (atau port I/O). CPU terus-menerus memonitor (polling) register kontrol yang terkait
dengan setiap port I/O. Ketika sebuah byte tiba di port, bit di register kontrol juga di-set. CPU akhirnya
memeriksa port dan memperhatikan bahwa bit kontrol “data siap" telah di-set.
• CPU me-reset bit kontrol, mengambil byte, dan memprosesnya sesuai dengan program yang diberikan untuk
port tertentu itu. Saat pemrosesan selesai, CPU melanjutkan polling register kontrol seperti sebelumnya.
• Manfaat menggunakan pendekatan ini adalah prosesor memiliki kontrol terprogram atas perilaku setiap
perangkat. Dengan memodifikasi beberapa baris kode, prosesor dapat menyesuaikan jumlah dan jenis
perangkat di sistem, serta prioritas dan interval polling. Bagaimanapun, polling register yang konstan merupakan
masalah. CPU berada dalam loop “sibuk menunggu" terus-menerus sampai mulai melayani permintaan I/O
tanpa melakukan pekerjaan apapun sampai ada I/O untuk diproses.
• Masalah lainnya adalah dalam memutuskan seberapa sering (interval) melakukan polling; beberapa perangkat
mungkin perlu ditengok lebih sering daripada yang lain. Karena keterbatasan ini, I/O terprogram paling sesuai
untuk sistem dengan fungsi khusus seperti mesin anjungan tunai mandiri dan sistem tertanam (embedded)
yang mengontrol atau memantau kondisi lingkungan.
Interrupt-Driven I/O (1)

• Metode kontrol yang lebih umum dan efisien adalah


interrupt-driven I/O. Pada interrupt-driven I/O,
alih-alih prosesor terus-menerus memantau
perangkat yang terpasang, perangkatlah memberi
tahu prosesor saat perangkat tersebut memiliki data
untuk dikirim. Prosesor melanjutkan tugas lain
sampai perangkat yang meminta layanan
mengirimkan interupsi ke prosesor. • Setiap perangkat periferal memiliki akses ke jalur permintaan
interupsi. Cip kontrol interupsi memiliki input untuk setiap
• Interupsi ini biasanya dibuat untuk setiap word jalur interupsi. Setiap kali jalur interupsi ditetapkan,
informasi yang ditransfer. Dalam kebanyakan pengontrol memecahkan kode interupsi dan menaikkan
implementasi interrupt-driven I/O, komunikasi ini input Interupsi (INT) pada prosesor. Saat proseesor siap
terjadi melalui perantara pengontrol interupsi. untuk memproses interupsi, ia mengirimkan sinyal
Sirkuit ini menangani sinyal interupsi dari semua pengakuan interupsi (INTA). Setelah pengontrol interupsi
perangkat I/O yang terpasang pada sistem. Setelah mendapatkan pengakuan ini, ia dapat menurunkan sinyal
sirkuit ini mengenali sinyal interupsi dari salah satu INT-nya.
perangkat yang terpasang, sirkuit ini memunculkan • Ketika dua atau lebih I/O interupsi terjadi secara bersamaan,
sinyal interupsi tunggal yang mengaktifkan jalur pengontrol interupsi menentukan mana yang harus
kontrol pada bus sistem. Jalurkontrol biasanya diutamakan, berdasarkan kekritisan waktu perangkat yang
terhubung langsung ke pin pada chip prosesor. meminta I/O.
Interrupt-Driven I/O (2)

Figure shows how the CPU finishes execution of the


current instruction and checks the status of its
interrupt pins (not just I/O) at the beginning of every
fetch–decode–execute cycle. Once the CPU
acknowledges the interrupt, it saves its current state
and processes the interrupt
Direct Memory Access
Drawbacks of Programmed and Interrupt-Driven I/O

• Interrupt-driven I/O, though more efficient than


simple programmed I/O, still requires the active
intervention of the processor to transfer data
between memory and an I/O module, and any data
transfer must traverse a path through the processor.

• When a system uses DMA, the CPU offloads


execution of tedious I/O instructions. To effect the
transfer, the CPU provides the DMA controller with
the location of the bytes to be transferred, the
number of bytes to be transferred, and the
destination device or memory address.
This communication usually takes place through
special I/O registers on the CPU. A sample DMA
configuration is shown. In this configuration, I/O and
memory share the same address space, so it is one
type of memory-mapped I/O.
DMA Function (1)

• DMA involves an additional module on


the system bus. The DMA module is
capable of mimicking the processor and,
indeed, of taking over control of the
system from the processor.
• It needs to do this to transfer data to and
from memory over the system bus. For
this purpose, the DMA module must use
the bus only when the processor does not
need it, or it must force the processor to
suspend
operation temporarily.
• The latter technique is more common and
is referred to as cycle stealing, because
the DMA module in effect steals a bus
cycle.
DMA Function (2)
When the processor wishes to read or write a block of data, it
issues a command to the DMA module, by sending to the
DMA module the following information:
• Whether a read or write is requested, using the read or write
control line between the processor and the DMA module
• The address of the I/O device involved, communicated on the
data lines
• The starting location in memory to read from or write to,
communicated on the data lines and stored by the DMA module
in its address register
• The number of words to be read or written, again communicated
via the data lines and stored in the data count register
• The processor then continues with other work. It has delegated
this I/O operation to the DMA module. The DMA module
transfers the entire block of data, one word at a time, directly to
or from memory, without going through the processor.
• When the transfer is complete, the DMA module sends an
interrupt signal to the processor. Thus, the processor is involved
only at the beginning and end of the transfer

Anda mungkin juga menyukai