Coa Module 4
Coa Module 4
Input-Output Organization
Input/output Subsystem
The I/O subsystem of a computer provides an efficient mode of communication between the
central system and the outside environment. It handles all the input-output operations of the
computer system.
Peripheral Devices
Input or output devices that are connected to computer are called peripheral devices. These
devices are designed to read information into or out of the memory unit upon command from the
CPU and are considered to be the part of computer system. These devices are also
called peripherals.
For example: Keyboards, display units and printers are common peripheral devices.
1. Input peripherals : Allows user input, from the outside world to the computer. Example:
Keyboard, Mouse etc.
2. Output peripherals: Allows information output, from the computer to the outside world.
Example: Printer, Monitor etc
Interfaces
Interface is a shared boundary btween two separate components of the computer system which can
be used to attach two or more components to the system for communication purposes.
There are two types of interface:
1. CPU Inteface
2. I/O Interface
When we type something from our keyboard, the input data is transferred to the computer's
CPU, and the screen displays the output data. But how does our computer's CPU or processors
share information with the external Input-Output devices? Well, we can achieve this with the
input-output Interface.
The below figure shows a typical input-output interface between the processor and different
peripherals:
The I/O buses include control lines, address lines, and data lines. In any general computer, the
printer, keyboard, magnetic disk, and display terminal are commonly connected. Every
peripheral unit has an interface associated with it. Every interface decodes the address and
control received from the I/O bus.
It can describe the control and address received from the computer peripheral and supports
signals for the computer peripheral controller. It can also conduct the transfer of information
or data between peripheral and processor and can also integrate the data flow.
The I/O buses are linked to all the peripheral interfaces from the computer processor. The
processor locates a device address on the address line for interaction with a specific device.
Every interface contains an address decoder that monitors the address lines, attached to the I/O
bus.
When the interface recognizes the address, it activates the direction between the bus and the
device that it controls. The interface will disable the peripherals whose address is not
equivalent to the address in the bus.
● It selects the peripheral appropriate for the interpretation of the input-output devices.
● It can convert digital data into analog signals and vice versa.
If the registers in the I/O interface share a common clock with CPU registers, then transfer between
the two units is said to be synchronous. But in most cases, the internal timing in each unit is
independent of each other, so each uses its private clock for its internal registers. In this case, the
two units are said to be asynchronous to each other, and if data transfer occurs between them, this
data transfer is called Asynchronous Data Transfer.
But, the Asynchronous Data Transfer between two independent units requires that control signals
be transmitted between the communicating units so that the time can be indicated at which they
send data. These two methods can achieve this asynchronous way of data transfer:
o Strobe control: A strobe pulse is supplied by one unit to indicate to the other unit when
the transfer has to occur.
o Handshaking: This method is commonly used to accompany each data item being
transferred with a control signal that indicates data in the bus. The unit receiving the data
item responds with another signal to acknowledge receipt of the data.
The strobe pulse and handshaking method of asynchronous data transfer is not restricted to I/O
transfer. They are used extensively on numerous occasions requiring the transfer of data between
two independent units. So, here we consider the transmitting unit as a source and receiving unit as
a destination.
For example, the CPU is the source during output or write transfer and the destination unit during
input or read transfer.
Therefore, the control sequence during an asynchronous transfer depends on whether the transfer
is initiated by the source or by the destination.
So, while discussing each data transfer method asynchronously, you can see the control sequence
in both terms when it is initiated by source or by destination. In this way, each data transfer method
can be further divided into parts, source initiated and destination initiated.
A. Source initiated strobe: In the below block diagram, you can see that strobe is initiated by source,
and as shown in the timing diagram, the source unit first places the data on the data bus.
B. Destination initiated strobe: In the below block diagram, you see that the strobe initiated
by destination, and in the timing diagram, the destination unit first activates the strobe
pulse, informing the source to provide the data.
The source unit responds by placing the requested binary information on the data bus. The
data must be valid and remain on the bus long enough for the destination unit to accept it.
The falling edge of the strobe pulse can use again to trigger a destination register. The
destination unit then disables the strobe. Finally, and source removes the data from the data
bus after a determined time interval.
In this case, the strobe may be a memory read control from the CPU to a memory unit. The
CPU initiates the read operation to inform the memory, which is a source unit, to place the
selected word into the data bus.
2. Handshaking Method
The strobe method has the disadvantage that the source unit that initiates the transfer has no way
of knowing whether the destination has received the data that was placed in the bus. Similarly, a
destination unit that initiates the transfer has no way of knowing whether the source unit has placed
data on the bus.
So this problem is solved by the handshaking method. The handshaking method introduces a
second control signal line that replays the unit that initiates the transfer.
In this method, one control line is in the same direction as the data flow in the bus from the source
to the destination. The source unit uses it to inform the destination unit whether there are valid data
in the bus.
The other control line is in the other direction from the destination to the source. This is because
the destination unit uses it to inform the source whether it can accept data. And in it also, the
sequence of control depends on the unit that initiates the transfer. So it means the sequence of
control depends on whether the transfer is initiated by source and destination.
o Source initiated handshaking: In the below block diagram, you can see that two
handshaking lines are "data valid", which is generated by the source unit, and "data
accepted", generated by the destination unit.
The timing diagram shows the timing relationship of the exchange of signals between the
two units. The source initiates a transfer by placing data on the bus and enabling its data
valid signal. The destination unit then activates the data accepted signal after it accepts the
data from the bus.
The source unit then disables its valid data signal, which invalidates the data on the bus.
After this, the destination unit disables its data accepted signal, and the system goes into
its initial state. The source unit does not send the next data item until after the destination
unit shows readiness to accept new data by disabling the data accepted signal.
This sequence of events described in its sequence diagram, which shows the above
sequence in which the system is present at any given time.
o Destination initiated handshaking: In the below block diagram, you see that the two
handshaking lines are "data valid", generated by the source unit, and "ready for data"
generated by the destination unit.
Note that the name of signal data accepted generated by the destination unit has been
changed to ready for data to reflect its new meaning.
The destination transfer is initiated, so the source unit does not place data on the data bus
until it receives a ready data signal from the destination unit. After that, the handshaking
process is the same as that of the source initiated.
The sequence of events is shown in its sequence diagram, and the timing relationship
between signals is shown in its timing diagram. Therefore, the sequence of events in both
cases would be identical.
Modes of Transfer
The binary information that is received from an external device is usually stored in the memory
unit. The information that is transferred from the CPU to the external device is originated from the
memory unit. CPU merely processes the information but the source and target is always the
memory unit. Data transfer between CPU and the I/O devices may be done in different modes. Data
transfer to and from the peripherals may be done in any of the three possible ways
1. Programmed I/O.
2. Interrupt- initiated I/O.
3. Direct memory access( DMA).
1. Programmed I/O
Programmed I/O uses the I/O instructions written in the computer program. The instructions in the
program initiate every data item transfer. Usually, the data transfer is from a memory and CPU
register. This case requires constant monitoring by the peripheral device's CPU.
I/O Commands
To execute an I/O-related instruction, the processor issues an address, specifying the particular I/O
module and external device, and an I/O command. There are four types of I/O commands that an I/O
module may receive when it is addressed by a processor:
● Control: Used to activate a peripheral and tell it what to do. For example, a magnetic-tape unit
may be instructed to rewind or to move forward one record. These commands are tailored to the
particular type of peripheral device.
● Test: Used to test various status conditions associated with an I/O module and its peripherals. The
processor will want to know that the peripheral of interest is powered on and available for use. It
will also want to know if the most recent I/O operation is completed and if any errors occurred.
● Read: Causes the I/O module to obtain an item of data from the peripheral and place it in an
internal buffer. The processor can then obtain the data item by requesting that the I/O module place
it on the data bus.
● Write: Causes the I/O module to take an item of data (byte or word) from the data bus and
subsequently transmit that data item to the peripheral.
Advantages:
● The processor has to wait for a long time for the I/O module to be ready for either transmission or
reception of data.
● The performance of the entire system is severely degraded.
2. Interrupt-initiated I/O
In the above section, we saw that the CPU is kept busy unnecessarily. We can avoid this situation by using
an interrupt-driven method for data transfer. The interrupt facilities and special commands inform the
interface for issuing an interrupt request signal as soon as the data is available from any device. In the
meantime, the CPU can execute other programs, and the interface will keep monitoring the i/O device.
Whenever it determines that the device is ready for transferring data interface initiates an interrupt request
signal to the CPU. As soon as the CPU detects an external interrupt signal, it stops the program it was
already executing, branches to the service program to process the I/O transfer, and returns to the program
it was initially running.
Interrupt driven I/O is an alternative scheme dealing with I/O. Interrupt I/O is a way of controlling
input/output activity whereby a peripheral or terminal that needs to make or receive a data transfer sends a
signal. This will cause a program interrupt to be set. At a time appropriate to the priority level of the I/O
interrupts. Relative to the total interrupt system, the processors enter an interrupt service routine. The
function of the routine will depend upon the system of interrupt levels and priorities that is implemented in
the processor. The interrupt technique requires more complex hardware and software, but makes far more
efficient use of the computer’s time and capacities. Figure 2 shows the simple interrupt processing.
For input, the device interrupts the CPU when
new data has arrived and is ready to be retrieved
by the system processor. The actual actions to
perform depend on whether the device uses I/O
ports or memory mapping.
Interrupt Processing
1. A device driver initiates an I/O request on behalf
of a process.
2. The device driver signals the I/O controller for
the proper device, which initiates the requested
I/O.
3. The device signals the I/O controller that is ready
to retrieve input, the output is complete or that an
error has been generated.
4. The CPU receives the interrupt signal on the
interrupt-request line and transfer control over
the interrupt handler routine.
5. The interrupt handler determines the cause of the
interrupt, performs the necessary processing and
executes a “return from” interrupt instruction.
6. The CPU returns to the execution state prior to
the interrupt being signaled.
7. The CPU continues processing until the cycle
begins again.
Advantages - fast
- efficient
Disadvantages - can be tricky to write if
using a low level language
- can be tough to get various
pieces to work well together
- usually done by the
hardware manufacturer / OS
maker, e.g. Microsoft
Working of CPU in terms of interrupts:
Priority Interrupt
A priority interrupt is a system which decides the priority at which various devices, which generates the
interrupt signal at the same time, will be serviced by the CPU. The system has authority to decide which
conditions are allowed to interrupt the CPU, while some other interrupt is being serviced. Generally, devices
with high speed transfer such as magnetic disks are given high priority and slow devices such
as keyboards are given low priority.
When two or more devices interrupt the computer simultaneously, the computer services the device with
the higher priority first.
Types of Interrupts:
Hardware Interrupts
When the signal for the processor is from an external device or hardware then this interrupts is known
as hardware interrupt.
Let us consider an example: when we press any key on our keyboard to do some action, then this pressing
of the key will generate an interrupt signal for the processor to perform certain action. Such an interrupt
can be of two types:
● Maskable Interrupt
The hardware interrupts which can be delayed when a much high priority interrupt has occurred at
the same time.
The hardware interrupts which cannot be delayed and should be processed by the processor
immediately.
Software Interrupts
The interrupt that is caused by any internal system of the computer system is known as a software interrupt.
It can also be of two types:
● Normal Interrupt
The interrupts that are caused by software instructions are called normal software interrupts.
● Exception
Unplanned interrupts which are produced during the execution of some program are
called exceptions, such as division by zero.
This way of deciding the interrupt priority consists of serial connection of all the devices which generates
an interrupt signal. The device with the highest priority is placed at the first position followed by lower
priority devices and the device which has lowest priority among all is placed at the last in the chain.
In daisy chaining system all the devices are connected in a serial form. The interrupt line request is common
to all devices. If any device has interrupt signal in low level state then interrupt line goes to low level state
and enables the interrupt input in the CPU. When there is no interrupt the interrupt line stays in high level
state. The CPU respond to the interrupt by enabling the interrupt acknowledge line. This signal is received
by the device 1 at its PI input. The acknowledge signal passes to next device through PO output only if
device 1 is not requesting an interrupt.
The following figure shows the block diagram for daisy chaining priority system.
4. Direct Memory Access (DMA)
DMA is a peripheral mostly found in modern Processors and Microcontrollers .DMA stands
for Direct Memory Access. This means you can perform memory read and write operations without
stealing CPU cycles. Let’s say you want to copy 1000 bytes from one memory location to another.
without DMA you have to read each byte then write that to the new location that means you need
2 cycles for each byte (assuming that you are performing this on a 8bit processor) , this totals to
2000 cycles. this is the load on CPU just for 1kB of memory .With DMA you can perform the same
task with just 2-10 cycle (you have to configure the DMA then leave it ) once it completes the
transfer it will fire an interrupt to let the CPU know that the transaction is complete.
The data transfer between any fast storage media like a memory unit and a magnetic disk gets
limited with the speed of the CPU. Thus it will be best to allow the peripherals to directly
communicate with the storage using the memory buses by removing the intervention of the CPU.
This mode of transfer of data technique is known as Direct Memory Access (DMA). During Direct
Memory Access, the CPU is idle and has no control over the memory buses. The DMA controller
takes over the buses and directly manages data transfer between the memory unit and I/O devices.
CPU Bus Signal for DMA transfer
Bus Request - We use bus requests in the DMA controller to ask the CPU to relinquish the control
buses.
Bus Grant - CPU activates bus grant to inform the DMA controller that DMA can take control of
the control buses. Once the control is taken, it can transfer data in many ways.
● Burst Transfer: In this transfer, DMA will return the bus control after the complete data transfer.
A register is used as a byte count, which decrements for every byte transfer, and once it becomes
zero, the DMA Controller will release the control bus. When the DMA Controller operates in burst
mode, the CPU is halted for the duration of the data transfer.
● Cyclic Stealing: It is an alternative method for data transfer in which the DMA controller will
transfer one word at a time. After that, it will return the control of the buses to the CPU. The CPU
operation is only delayed for one memory cycle to allow the data transfer to “steal” one memory
cycle.
Advantages
Memory Organization:
The memory of system can be thought of as a large number of addressable storage locations. Each
location can store a fixed amount of data, typically measured in bits or bytes. The way these
locations are organized and accessed can have a notable impact on the overall production and
functionality of the system.
Memory organization involves the use of different types of memory, including RAM, ROM, cache
memory, virtual memory, flash memory, and magnetic disks. Each type of memory is used for a
specific purpose and has its own advantages and disadvantages.
Memory organization is also important for the efficient management of data and instructions
within a computer system. It involves techniques such as memory allocation, virtual memory
management, and cache management. These techniques help to optimize the use of memory and
improve system performance. Overall, memory organization is a critical aspect of computer
architecture that plays a important role in determining the performance, functionality, and
efficiency of a computer system.
I. Von Neumann architecture: This type of memory organization is named after the computer
scientist John von Neumann, who first proposed the concept. In this architecture, in the same
memory we can store both instructions and data. This memory organization is simple and easy to
implement, but it can lead to bottlenecks as the system tries to access both instructions and data at
the same time.
II. Harvard architecture: In this type of memory organization, program instructions and data are
stored in separate memory spaces. This allows for parallel access to instructions and data, which
can lead to faster performance. However, the Harvard architecture is more complex to implement
and may require more hardware resources.
III. Cache memory organization: Small, fast memory that stores frequently used data and
instructions. Cache memory is organized into levels, with each level providing increasing storage
capacity and decreasing speed. Cache memory organization is critical for improving system
performance, as it reduces the time it takes to access frequently used data and instructions.
IV. Virtual memory organization: It is a technique that allows a computer to use more memory
than it physically has. Virtual memory creates a virtual address space that is mapped to the physical
memory. This memory organization is critical for running large applications that require more
memory than is available on the system.
V. Flash memory organization: It is a non-volatile memory that is used in portable devices, such
as USB drives and memory cards. Flash memory organization involves dividing the memory into
blocks and pages, with data stored in individual pages. This allows for efficient read and writes
operations and makes flash memory ideal for storing data in portable devices.
Memory distribution: The system must be able to distribute memory to processes as needed.
Additionally, the system must make sure that memory is allocated as effectively as possible in
order to reduce fragmentation.
Memory security: The system must prevent other processes from improperly accessing the
memory allotted to each process. Furthermore, it should make sure that processes are unable to
alter memory that does not belong to them.
Deallocating memory: The system must be able to release memory that is no longer required by
a running process. This involves restoring RAM to the system after it has been freed up and is no
longer needed.
Virtual memory: The system must be capable of offering virtual memory, which enables
programmes to access more memory than is physically accessible. By switching data between the
RAM and the hard drive, this is accomplished.
Memory fragmentation can happen when memory is frequently allocated and deallocated; the
system should avoid this. Fragmentation might result in memory usage that is wasteful and slow
down the system.
Memory mapping: The system ought to support memory mapping, which permits the mapping
of files to memory. As data can be read and written directly from memory, this may speed up file
I/O processes.
Memory leaks are caused when a process fails to deallocate memory that it no longer requires.
The system should be able to identify and prevent memory leaks.
Main Memory
The main memory is the central storage unit. It is an essential component of a digital computer
since it stores data and programs.
It is of two types:
● RAM (Random Access Memory)
● ROM (Read Only Memory)
RAM: It's a volatile memory. Volatile memory stores data that is dependent on the power supply.
If the power supply fails, is interrupted, or is turned off, all Data and Information on this memory
will be erased. RAM is utilized to start or boot up the computer. Read this to learn more about
RAM.
ROM: It is a type of non-volatile memory. Non-volatile memory keeps data even if the power
source is turned off. The data that is used to run the system is stored in the ROM.
RAM (Random Access Memory): AM is a type of computer memory that allows data to be read
or written in any order. It is a volatile memory that can be accessed randomly and is used to store
data and programs temporarily while they are being used.
The memory unit that communicates directly within the CPU, Auxillary memory and Cache
memory, is called main memory. It is the central storage unit of the computer system. It is a large
and fast memory used to store data during computer operations. Main memory is made up
of RAM and ROM, with RAM integrated circuit chips holing the major share.
RAM integrated circuit chips
A static RAM's main components are flip-flops, which store binary data. The information stored
in RAM chips is volatile, which means it will remain valid as long as the device is powered on.
Characteristics of a RAM chip:
1. A RAM chip is suited for communication with the CPU if it has one or more control inputs
that choose the chip only when needed.
2. A bidirectional data bus is another typical feature that allows data to be transferred from
memory to CPU during a read operation and from CPU to memory during a write operation.
3. The logic 1 and 0 signals are standard digital signals.
4. RAM chips come in a variety of sizes and are used based on the needs of the system.
5. The RAM chips are further classified into two modes, static and dynamic.
o SRAM: Static RAM, has a six transistor circuit in each cell and retains data, until
powered off.
o NVRAM: Non-Volatile RAM, retains its data, even when turned off. Example:
Flash memory.
ROM: Read Only Memory, is non-volatile and is more like a permanent storage for information.
It also stores the bootstrap loader program, to load and start the operating system when computer
is turned on. PROM(Programmable ROM), EPROM(Erasable PROM) and EEPROM(Electrically
Erasable PROM) are some commonly used ROMs. ROM (Read-Only Memory):ROM, or Read-
Only Memory, is a type of computer memory that is non-volatile, meaning that it retains its
contents even when the power is turned off. As the name suggests, ROM is read-only, meaning
that data can be read from it, but it cannot be written to.
Secondary memory is used for different purposes but the main purposes of using secondary
memory are:
● Permanent storage: As we know that primary memory stores data only when the power supply
is on, it loses data when the power is off. So we need a secondary memory to stores data
permanently even if the power supply is off.
● Large Storage: Secondary memory provides large storage space so that we can store large data
like videos, images, audios, files, etc permanently.
● Portable: Some secondary devices are removable. So, we can easily store or transfer data from
one computer or device to another.
1. Fixed storage
In secondary memory, a fixed storage is an internal media device that is used to store data in a
computer system. Fixed storage is generally known as fixed disk drives or hard drives. Generally,
the data of the computer system is stored in a built-in fixed storage device. Fixed storage does not
mean that you can not remove them from the computer system, you can remove the fixed storage
device for repairing, for the upgrade, or for maintenance, etc. with the help of an expert or
engineer.
Types of fixed storage:
Following are the types of fixed storage:
2. Removable storage
In secondary memory, removable storage is an external media device that is used to store data in
a computer system. Removable storage is generally known as disks drives or external drives. It is
a storage device that can be inserted or removed from the computer according to our requirements.
We can easily remove them from the computer system while the computer system is running.
Removable storage devices are portable so we can easily transfer data from one computer to
another. Also, removable storage devices provide the fast data transfer rates associated with
storage area networks (SANs).
1. Floppy Disk: A floppy disk consists of a magnetic disc in a square plastic case. It is used to
store data and to transfer data from one device to another device. Floppy disks are available in two
sizes (a) Size: 3.5 inches, the Storage capacity of 1.44 MB (b) Size: 5.25 inches, the Storage
capacity of 1.2 MB. To use a floppy disk, our computer needs to have a floppy disk drive. This
storage device becomes obsolete now and has been replaced by CDs, DVDs, and flash drives.
2. Compact Disc: A Compact Disc (CD) is a commonly used secondary storage device. It contains
tracks and sectors on its surface. Its shape is circular and is made up of polycarbonate plastic. The
storage capacity of CD is up to 700 MB of data. A CD may also be called a CD-ROM (Compact
Disc Read-Only Memory), in this computers can read the data present in a CD-ROM, but cannot
write new data onto it. For a CD-ROM, we require a CD-ROM. CD is of two types:
● CD-R (compact disc recordable): Once the data has been written onto it cannot be erased, it
can only be read.
● CD-RW (compact disc rewritable): It is a special type of CD in which data can be erased and
rewritten as many times as we want. It is also called an erasable CD.
3. Digital Versatile Disc: A Digital Versatile Disc also known as DVD it is looks just like a CD,
but the storage capacity is greater compared to CD, it stores up to 4.7 GB of data. DVD-ROM
drive is needed to use DVD on a computer. The video files, like movies or video recordings, etc.,
are generally stored on DVD and you can run DVD using the DVD player. DVD is of three types:
● DVD-ROM(Digital Versatile Disc Readonly): In DVD-ROM the manufacturer writes the
data in it and the user can only read that data, cannot write new data in it. For example movie
DVD, movie DVD is already written by the manufacturer we can only watch the movie but we
cannot write new data into it.
● DVD-R(Digital Versatile Disc Recordable): In DVD-R you can write the data but only one
time. Once the data has been written onto it cannot be erased, it can only be read.
● DVD-RW(Digital Versatile Disc Rewritable and Erasable): It is a special type of DVD in
which data can be erased and rewritten as many times as we want. It is also called an erasable
DVD.
4. Blu-ray Disc: A Blu-ray disc looks just like a CD or a DVD but it can store data or information
up to 25 GB data. If you want to use a Blu-ray disc, you need a Blu-ray reader. The name Blu-ray
is derived from the technology that is used to read the disc ‘Blu’ from the blue-violet laser and
‘ray’ from an optical ray.
5. Hard Disk: A hard disk is a part of a unit called a hard disk drive. It is used to storing a large
amount of data. Hard disks or hard disk drives come in different storage capacities.(like 256 GB,
500 GB, 1 TB, and 2 TB, etc.). It is created using the collection of discs known as platters. The
platters are placed one below the other. They are coated with magnetic material. Each platter
consists of a number of invisible circles and each circle having the same centre called tracks. Hard
disk is of two types (i) Internal hard disk (ii) External hard disk.
6. Flash Drive: A flash drive or pen drive comes in various storage capacities, such as 1 GB, 2
GB, 4 GB, 8 GB, 16 GB, 32 GB, 64 GB, up to 1 TB. A flash drive is used to transfer and store
data. To use a flash drive, we need to plug it into a USB port on a computer. As a flash drive is
easy to use and compact in size, Nowadays it is very popular.
7. Solid-state disk: It is also known as SDD. It is a non-volatile storage device that is used to store
and access data. It is faster, does noiseless operations(because it does not contain any moving parts
like the hard disk), consumes less power, etc. It is a great replacement for standard hard drives in
computers and laptops if the price is low and it is also suitable for tablets, notebooks, etc because
they do not require large storage.
8. SD Card: It is known as a Secure Digital Card. It is generally used in portable devices like
mobile phones, cameras, etc., to store data. It is available in different sizes like 1 GB, 2 GB, 4 GB,
8 GB, 16 GB, 32 GB, 64 GB, etc. To view the data stored in the SD card you can remove them
from the device and insert them into a computer with help of a card reader. The data stores in the
SD card is stored in memory chips(present in the SD Card) and it does not contain any moving
parts like the hard disk.
Cache Memory:
To temporarily store frequently accessed data and instructions, systems use cache memory, a
compact, high-speed memory. It is situated between the CPU and the main memory of the
computer and is a part of the hierarchy of memory.
The cache memory is always checked by the CPU before it can access any data or instructions.
The system performs better and saves time if the data or instruction is discovered in the cache.
When information is not located in the cache, it must be accessed from the main memory, which
takes additional time.
· The concept of locality of reference governs how cache memory functions. Consequently,
frequently accessed information and instructions are likely to be used once more soon.
The ability to quickly access frequently used data and instructions thanks to cache memory
considerably boosts system performance. As a result, cache memory is a crucial part of modern
computer organization.
Cache Performance:
• Before reading or writing to a location in main memory, the processor looks for the associated
entry in cache.
• Data is read from cache when a cache hit occurs when the CPU determines that a memory
location is in cache.
• A cache miss is the technical term for when the CPU cannot find a location in cache. If there is
a cache miss, a new entry is allocated, the data is copied from main memory, and the request is
satisfied from the contents of the cache.
• Hit ratio is a commonly used measure to assess the effectiveness of cache memory. • Hit rate is
calculated as follows.
Hit Rate = Hits / (Hits + Misses) = Hits / Total Hits.
Cache Mapping
Cache mapping refers to a technique using which the content present in the main memory is
brought into the memory of the cache. Three distinct types of mapping are used for cache memory
mapping.
● The word that is required isn’t present in the memory of the cache.
● The page consists of the required word that we need to map from the main memory.
● We can perform such a type of mapping using various different techniques of cache
mapping.
Let us discuss different techniques of cache mapping in this article.
In simpler words, cache mapping refers to a technique using which we bring the main memory
into the cache memory. Here is a diagram that illustrates the actual process of mapping:
Cache line number = (Address of the Main Memory Block ) Modulo (Total number of lines in
Cache)
For example,
● Let us consider that particular cache memory is divided into a total of ‘n’ number of
lines.
● Then, the block ‘j’ of the main memory would be able to map to line number only of the
cache (j mod n).
● The main memory block is capable of mapping to any given line of the cache that’s
available freely at that particular moment.
● It helps us make a fully associative mapping comparatively more flexible than direct
mapping.
For Example
Let us consider the scenario given as follows:
Here, we can see that,
● The grouping of the cache lines occurs into various sets where all the sets consist of k
number of lines.
● Any given main memory block can map only to a particular cache set.
● However, within that very set, the block of memory can map any cache line that is freely
available.
● The cache set to which a certain main memory block can map is basically given as
follows:
Cache set number = ( Block Address of the Main Memory ) Modulo (Total Number of sets
present in the Cache)
For Example
Let us consider the example given as follows of a two-way set-associative mapping:
In this case,
● The k-way set associative mapping refers to a combination of the direct mapping as well
as the fully associative mapping.
● It makes use of the fully associative mapping that exists within each set.
● Therefore, the k-way set associative mapping needs a certain type of replacement
algorithm.
Division of Physical Address
In the case of fully k-way set mapping, the division of the physical address occurs as follows:
Special Cases
● In case k = 1, the k-way set associative mapping would become direct mapping. Thus,
Direct Mapping = one-way set associative mapping
● In the case of k = The total number of lines present in the cache, then the k-way set
associative mapping would become fully associative mapping.