COA-Module 4 Notes
COA-Module 4 Notes
● Registers are the smallest and fastest memory units located directly
within the CPU.
● They hold data temporarily while the CPU performs operations, like
arithmetic or data manipulation.
● Since they are directly accessible by the CPU, registers provide very
high-speed access compared to other memory types.
● Common examples of registers include the Accumulator (for storing
results of operations), Program Counter (for keeping track of
instruction locations), and General Purpose Registers.
● This is the primary storage area that the CPU uses to store data and
instructions during program execution.
● Main Memory typically refers to RAM (Random Access Memory),
which is fast but volatile (data is lost when the system powers off).
● Internal memory may include one or more levels of cache:
○ Cache is a small, very fast type of memory that sits between the
CPU and main memory. It's used to store frequently accessed
data, reducing the time needed for the CPU to retrieve
information.
○ Cache levels are usually labeled as L1, L2, and L3—with L1 being
the smallest and fastest, and L3 being larger but slower.
● RAM provides the CPU with quick access to data and instructions
necessary for current processes, and it is larger than cache but slower
than registers.
Q3)What is RAM?
A:
RAM (Random Access Memory) is a type of volatile memory that allows data
to be read from or written to any location directly (randomly), without going
through other memory locations sequentially. It’s the primary memory in a
computer system, playing a critical role in the performance of applications
and processes.
● Bits Stored as On/Off Switches: SRAM stores each bit using a set of
transistors configured as a flip-flop, which holds the data in a stable
state without needing refreshing.
● No Charge Leakage: Unlike DRAM, SRAM does not rely on capacitors,
so there is no charge to leak, and data remains stable as long as power
is supplied.
● No Refreshing Required: Since SRAM does not lose charge, it does not
need refreshing, which allows for faster access times compared to
DRAM.
● More Complex Construction: SRAM cells use more transistors per bit
(typically 4-6), making it more complex and physically larger than
DRAM.
● Higher Cost: Due to its complex construction, SRAM is more expensive
than DRAM per bit.
● Faster Performance: SRAM’s lack of refresh cycles makes it
significantly faster, which is why it is often used for cache memory
close to the CPU.
● Digital Nature: Unlike the analog nature of DRAM, SRAM operates
digitally, with each bit represented by a stable, discrete on/off state
(flip-flop).
In summary, SRAM is a fast, stable type of memory often used for cache due
to its non-volatile behavior during power, higher speed, and reliability,
though it comes at a higher cost and with less density than DRAM.
Q8)What is ROM?
A:
Characteristics of ROM:
● Non-volatile: Data is retained even when the device is powered off.
● Read-only: The data stored in ROM can be read, but typically cannot
be modified (depending on the type).
● Used for firmware: Typically stores low-level system instructions, like
the BIOS in a computer or firmware in devices like printers and routers.
● Durable and reliable: Since the data is etched permanently (in the
case of traditional ROM), it is highly resistant to data corruption.
Q9)What is PROM?
A:
A:
A:
A:
A:
Cache is a small amount of fast memory- which sits between the main
memory and CPU. It may be located on CPU chip or module. It is used to
store data required in regular cases.
A:
Q15)What is Tag?
A:
Q16)Explain the differences between L1, L2, and L3 cache in terms of speed,
size, and location.
A:
● L1 Cache: This is the smallest and fastest cache, located directly on the
CPU chip. It has a very small capacity (usually 16KB to 128KB) and is
used for quick access to frequently used data and instructions.
● L2 Cache: Larger than L1, with more capacity (typically 128KB to
several MB), and located either on the CPU chip or on a separate chip
near the CPU. It is slower than L1 but still faster than RAM and helps
improve CPU performance by storing data that L1 might not have.
● L3 Cache: This is the largest and slowest among the three, often
shared by multiple CPU cores. It can be several MB to tens of MB in
size. It helps improve the performance of both L1 and L2 by storing a
larger pool of data, with access speeds roughly twice that of RAM.
A:
● Size: The size of the cache determines how much data can be stored,
affecting performance and cost; larger caches generally improve speed
but increase cost.
● Mapping Function: The mapping function defines how data from main
memory is assigned to cache locations, impacting cache efficiency and
access time.
● Replacement Algorithm: This algorithm decides which data to evict
when the cache is full, with common strategies like LRU (Least
Recently Used) or FIFO (First In First Out).
● Write Policy: Determines how data is written to cache and main
memory, with strategies like write-through (immediate write to
memory) and write-back (write only when data is evicted).
● Block Size: Refers to the amount of data fetched from memory in a
single cache line, affecting the trade-off between data locality and
cache efficiency.
● Number of Caches: This refers to how many levels of cache exist (L1,
L2, L3) and their respective sizes, impacting overall system
performance.
● Cost: More cache increases the overall cost of the system due to the
need for more physical memory and more complex cache
management.
● Speed: Larger caches can improve system speed by reducing the need
to access slower main memory, but there’s a point where adding more
cache yields diminishing returns.
● Checking Cache for Data Takes Time: While caches improve speed,
checking multiple levels of cache for data introduces overhead,
particularly in systems with deep cache hierarchies.
A:
1. Tag Field: The tag field stores the higher-order bits of the memory
address and is used to check if the requested data is in the cache.
2. Line Field: The line field selects which cache line the data might be
stored in by using the middle portion of the memory address.
3. Word Field: The word field selects the specific word within the cache
line when multiple words are stored in each line.
Q20)What is direct mapping?
A:
Key Points:
Advantages of Direct-mapping
Disadvantages of Direct-mapping
A:
Key Points:
● In associative mapping, the Tag field holds the entire address (without
any predefined index or line field), and every cache line can store any
memory block.
● There is no fixed relationship between a memory block and a cache
line, so the cache controller must search through all the cache lines to
check if the required data is present (cache lookup).
● Tag field is compared with all cache lines to determine a hit or miss.
A main memory block can load into any line of cache • Memory address is
interpreted as tag and word • Tag uniquely identifies block of memory •
Every line’s tag is examined for a match • Cache searching gets expensive.
A:
Set-Associative Mapping is a cache mapping technique that combines
aspects of both direct mapping and associative mapping. In this method,
the cache is divided into multiple sets, and each set contains a fixed number
of lines (or slots). A given block of memory can be stored in any of the lines
within a specific set.
Key Points:
1. Cache divided into sets: The cache is organized into multiple sets, each
containing a small number of cache lines.
2. Each set contains a number of lines: Each set can store a predefined
number of cache lines (e.g., 2, 4, etc.).
3. Block maps to any line in a set: A memory block is mapped to one of
the lines in a specific set, but not to a particular line in the cache. The
block can go into any available line within the set.
4. Example (2-way set associative): If there are 2 lines per set, it's called
2-way associative mapping, meaning that a given memory block can
be placed in either of the 2 lines of one set.
Brushing up on Associative & Set Associative Mapping:
Associative Mapping:
A:
1. Write Policies:
○ Write-Through: Updates to a cache are immediately written to
main memory, ensuring all caches see the latest data but
increasing memory traffic.
○ Write-Back: Updates occur only in the cache and are written to
memory later, reducing traffic but requiring additional coherence
mechanisms.
2. Coherence Protocols:
○ MESI Protocol: Defines states (Modified, Exclusive, Shared,
Invalid) for cache lines to track and manage shared data
consistency.
○ Snoopy Protocols: Each cache controller monitors a shared bus
for changes, updating or invalidating its data as needed to
maintain consistency.
Solutions
A:
A:
A:
A:
Write Back- where updates are initially made only to the cache and not
directly to main memory, along with some of the challenges this creates.
Here’s a detailed breakdown of each point:
A:
Write Update:
A:
Write Invalidate:
When a write is required, all other caches of the line are invalidated:
Writing processor then has exclusive access until line required by another
processor:
● Each cache line is labeled with a state: Modified (only one processor
has changed it), Exclusive (one processor holds it without modifying),
Shared (multiple processors have read-only access), or Invalid (data is
outdated). These states help the system maintain coherence
efficiently.
MESI protocol:
A:
A:
Here’s an explanation of interleaved memory in three lines for each point:
A:
A:
Q34)What is Paging?
A:
A:
A:
A:
LRU Replacement
FIFO Replacement
OPT Replacement
Q38) Name some Secondary Storage devices.
A:
Secondary Storage
● Magnetic disks
● Floppy disks
● Magnetic Tape
● RAID
● Optical Memory
● CD-ROM
● DVD
A:
RAID Levels 0 - 6
● RAID 0 (Striping):
○ Data is split across multiple disks (striped) for improved
performance but no redundancy. If one disk fails, all data is lost.
● RAID 1 (Mirroring):
○ Data is duplicated on two or more disks. Provides redundancy,
meaning if one disk fails, the data is still available on the other
disk, but with no performance improvement.
RAID Level 2 - Hamming Code:
RAID 2 uses bit-level striping with Hamming code for error correction. Each
bit of data is stored across different disks, and error correction information is
stored on additional disks using the Hamming code. This setup provides fault
tolerance, but it is rarely used today due to inefficiency and the existence of
better alternatives like RAID 3 and RAID 5
RAID Level 3 - Bit Interleaved Parity:
● RAID 3 uses bit-level striping, where data is broken into bits and
distributed across disks, with one dedicated disk for parity. This parity
disk holds error-checking information, allowing the system to recover
from a single disk failure. The main drawback is the potential
bottleneck of the parity disk during write operations.
RAID Level 4 - Block Level Parity:
● RAID 5 also uses block-level striping, but unlike RAID 4, the parity data
is distributed across all the disks in the array. This improves
performance since there is no dedicated parity disk, and the array can
tolerate the failure of one disk without losing data. RAID 5 is
commonly used for balancing fault tolerance and performance.
RAID Level 6 - Dual Redundancy:
● RAID 6 is similar to RAID 5 but adds double parity, storing two sets of
parity data distributed across the disks. This provides dual
redundancy, allowing the system to tolerate the failure of two disks
simultaneously. It offers higher fault tolerance but comes at the cost of
slower write performance due to the additional parity calculations.