DSCO UNIT4 modified
DSCO UNIT4 modified
and
Memory
UNIT - 4
Processor Memory
Bus
2) I/O-Mapped I/O
◻ Memory and I/O address-spaces are different.
◻ A special instructions named IN and OUT are used for
data-transfer.
◻ Advantage of separate I/O space: I/O-devices deal
with fewer address-lines.
1. Memory-Mapped I/O
What happens? I/O devices (like keyboards and monitors) share the same address space as memory.
How to use? You can use normal instructions like Move or Load to send/receive data to/from I/O devices, just like working with memory.
Example:
Move DATAIN, R0: Reads data from a keyboard (input buffer) to register R0.
Move R0, DATAOUT: Sends data from R0 to a monitor (output buffer).
2. I/O-Mapped I/O
What happens? I/O devices use a separate address space from memory.
How to use? Special instructions like IN and OUT are used to talk to I/O devices.
Advantage: I/O devices need fewer address lines, so the hardware is simpler.
Dr Yogish H K, Professor, Dept. of ISE
I/O Interface for an Input Device
9
An I/O Interface is like a middleman between an input device (like a keyboard) and the system's bus (communication pathway). Here's how it
works:
Input device
The processor actively checks (or "polls") if the I/O device is ready for data transfer.
Example: Continuously checking if a printer is ready to print. Dr Yogish H K, Professor, Dept. of ISE
Problem: Inefficient, as the processor wastes time waiting.
MECHANISMS USED FOR INTERFACING
I/O-DEVICES..
12
2) Interrupt I/O
• I/O-device initiates the action instead of the processor.
• I/O-device sends an INTR signal over bus whenever it is ready
for a data-transfer operation.
• Like this, required synchronization is done between processor
Interrupt I/O:
& I/O device. The I/O device sends an interrupt signal to the processor when it’s ready.
Example: A keyboard sends an interrupt when a key is pressed.
3) Direct Memory Access (DMA) Advantage: Processor doesn’t waste time polling; it responds only when needed.
16
interrupt request
Problem with Repeated Interrupts: If the interrupt-request signal remains active and triggers multiple interruptions while the
processor is handling an interrupt, it could lead to an infinite loop where the system keeps handling interrupts without ever
returning to the main program. This would make the system stuck. Dr Yogish H K, Professor, Dept. of ISE
Enabling and Disabling Interrupts.
24
Arbitration refers to the process of determining the order or priority in which multiple competing requests
are granted access to a shared resource, such as a processor or communication bus.
interrupt request lines
INTR1 I NTRp
Processor
INTA1 INTA p
- **Priority Arbitration:**
- When a device sends an interrupt request, it goes through a **priority arbitration circuit** in the processor.
- The processor will **only accept an interrupt request** if the interrupt has a **higher priority** than the current priority level of the processor.
- **Handling Requests:**
- This scheme ensures that **higher-priority interrupts** are processed first, even if a lower-priority interrupt is already being serviced.
◻
which When simultaneous requests are to be handled
- If multiple devices request an interrupt at the same time, the processor needs a way to prioritize and select
request to service first.
from two or more devices of the same type,
### . **Shared Interrupt Request Line:**
processor
- **Polling:** Devices sharemust have
a single interrupt means
request of deciding
line. The processor which
checks the status of each device in
sequence. The order of polling determines which device's request will be serviced first. This means the first
request
device checked to service first.
will be prioritized.
- **Priority Handling:** You could assign priorities to devices based on the order in which the processor polls
In this case several devices share one interrupt-
them. The higher-priority device will be serviced first.
◻
- In therequest line.
### **Vector Interrupts:**
case of **vectored interrupts**, each device sends an interrupt vector to the processor, which tells the
processor the address of the interrupt service routine (ISR) for that device.
◻ Polling
- **Ensuring statusIt’sregisters
Single Selection:** important to ensureofthatsuch devices
only one device sends its is simple,
interrupt vector at a
time, preventing conflicts. This is typically handled by the processor’s interrupt arbitration system, which ensures
only onepriority isvector
device's interrupt determined
is acknowledged, evenbyif multiple
the order ofrequests
devices make polling.
simultaneously.
This way,
◻ When
the system vector interrupts
ensures that interrupt
send requests at the same time.
are
handling is orderly used,
and preventsit must
conflicts whenbemultiple devices
•When I/O devices were organized into a priority structure, each device had its
own interrupt-request and interrupt-acknowledge line.
•When I/O devices were organized in a daisy chain fashion, the devices shared
an interrupt-request line, and the interrupt-acknowledge propagated through
the devices.
•A combination of priority structure and daisy chain scheme can also used.
52
### devices
2. **Block or Burst such
Mode**:as Disk, high-speed network Interface,
- The **DMA controller** gets **full control** of the memory and transfers a **large block** of data all at once without any
Graphic display device etc.,
interruptions.
- The processor has to wait until the DMA controller finishes its task.
Since Processor
- **Example**: originates
Imagine transferring most
a big file from memory
without letting the processor do anything until it's done.
to a of
disk.the
The DMAmemory access
controller will transfer the whole file at once
BUS Master:
A device that is allowed to initiate the data transfer on the bus
at given time is called bus master.
Bus arbitration:
The process by which the next device is to become bus
master is selected and bus mastership is transferred.
Priority:
The selection of bus master shall take into account the needs
of various devices by establishing priority system for
gaining access to the bus.
BUS Master:
A device that is allowed to initiate the data transfer on the bus
at given time is called bus master.
Bus arbitration:
The process by which the next device is to become bus
master is selected and bus mastership is transferred.
Priority:
The selection of bus master shall take into account the needs
of various devices by establishing priority system for
gaining access to the bus.
59
bus busy line
bus request
bus granted
60
61
The timing diagram shows the sequence of events for the devices connected to the
processor.
• DMA controller-2
→ requests and acquires bus-mastership and
→ later releases the bus. (Figure: 4.21).
• After DMA controller-2 releases the bus, the processor resources bus-mastership.
62
63
A winner is selected as a result of interaction among signals transmitted over these lines.
• Net-outcome is that the code on 4 lines represents request that has the highest ID number.
• Advantage:
This approach offers higher reliability since operation of bus is not dependent on any single
device.
For example:
Assume 2 devices A & B have their ID 5 (0101), 6 (0110) and their
code is 0111.
Each device compares the pattern on the arbitration line to its own ID
starting from MSB.
If the device detects a difference at any bit position, it disables the
drivers at that bit position.
Driver is disabled by placing ”0” at the input of the driver.
In e.g. “A” detects a difference in line ARB1, hence it disables the
drivers on lines ARB1 & ARB0.
This causes pattern on arbitration-line to change to 0110. This means
that “B” has won
contention. Dr Yogish H K, Professor, Dept. of ISE
A big challenge in the design of a computer system
is to provide a sufficiently large memory, with a
reasonable speed at an affordable cost.
Static RAM:
Very fast, but expensive, because a basic SRAM cell has a complex circuit making it
impossible to pack a large number of cells onto a single chip.
Dynamic RAM:
Simpler basic cell circuit, hence are much less expensive, but significantly slower than
SRAMs.
Magnetic disks:
Storage provided by DRAMs is higher than SRAMs, but is still less than what is
necessary.
Secondary storage such as magnetic disks provide a large amount
of storage, but is much slower than DRAMs.
Processor •Fastest access is to the data held in
processor registers. Registers are at
Registers the top of the memory hierarchy.
Increasing Increasing Increasing
•Relatively small amount of memory that
size speed cost per bit can be implemented on the processor
Primary L1
cache chip. This is processor cache.
•Two levels of cache. Level 1 (L1) cache
is on the processor chip. Level 2 (L2)
cache is in between main memory and
SecondaryL2 processor.
cache
•Next level is main memory, implemented
as SIMMs. Much larger, but much slower
than cache memory.
Main •Next level is magnetic disks. Huge amount
memory of inexepensive storage.
•Speed of memory access is critical, the
idea is to bring instructions and data
Magnetic disk
that will be used in the near future as
secondary close to the processor as possible.
memory
Processor is much faster than the main memory.
As a result, the processor has to spend much of its time waiting while instructions
and data are being fetched from the main memory.
Major obstacle towards achieving good performance.
Speed of the main memory cannot be increased
beyond a certain point.
Cache memory is an architectural arrangement
which makes the main memory appear faster to
the processor than it really is.
Cache memory is based on the property of
computer programs known as “locality of
reference”.
Main
Processor Cache memory
Write-through protocol is used, then the contents of the main memory are
updated directly.
If write-back protocol is used, the block containing the
addressed word is first brought into the cache. The desired word
is overwritten with new information.
Mapping functions determine how memory
blocks are placed in the cache.
A simple processor example:
Cache consisting of 128 blocks of 16 words each.
Total size of cache is 2048 (2K) words.
Main memory is addressable by a 16-bit address.
Main memory has 64K words.
Main memory has 4K blocks of 16 words each.
Three mapping functions:
Direct mapping
Associative mapping
Set-associative mapping. SAD
Main
memory Block 0 •Block j of the main memory maps to j modulo 128 of
Block 1
the cache. 0 maps to 0, 129 maps to 1.
Cache
tag
•More than one memory block is mapped onto the same
Block 0 position in the cache. e.g., Block 0 and Block 128 both map to
Cache Block 0).
tag
Block 1 •May lead to conflict for cache blocks even if the
cache is not full.
Block 127
•Resolve the conflict by allowing new block to
Block 128 replace the old block, leading to a trivial replacement
tag
Block 127 Block 129
algorithm.
•Memory address is divided into three fields:
- Low order 4 bits determine one of the 16
words in a block.
- When a new block is brought into the cache,
Block 255 the the next 7 bits determine which cache
Tag Block Word
5 7 4 Block 256 block this new block is placed in.
- High order 5 bits determine which of the possible
Main memory address Block 257
32 blocks is currently present in the cache. These
Offset (4 bits): Identifies the specific word
within a block (16 words per block). are tag bits.
Cache Index (7 bits): Identifies the specific
cache block (128 blocks in the cache). •Simple to implement but not very flexible.
Tag (5 bits): Differentiates which memory
block is stored in the cache block.
Block 4095
Main Block 0
memory Any main memory block can be placed in any cache block (unlike direct mapping).
Block 1
•Main memory block can be placed into any cache
Cache
tag
position.
Block 0 •Memory address is divided into two fields:
tag
Block 1 - Low order 4 bits identify the word within a block.
- High order 12 bits are tag bits identify a memory
Block 127
block when it is resident in the cache.
Block 128 •Flexible, and uses cache space efficiently.
tag
Block 127 Block 129
•Replacement algorithms can be used to replace an
existing block in the cache when the cache is full.
•Cost is higher than direct-mapped cache because of
the need to search all 128 patterns to determine
whether a given block is in the cache.
Block 255
Tag Word
12 4 Block 256