IAE Academy

GATE CS

Memory hierarchy, performance and cache mapping

A memory hierarchy gives the processor close to cache speed at close to main-memory cost per bit, and it works because programs show locality of reference. Hit ratio and average access time measure how well it works. The access time depends on a convention you must fix first: hierarchical access (a miss costs the cache check plus the memory time) or simultaneous access (a miss costs the memory time only). Direct-mapped, set-associative and fully associative mapping decide where a block may live and how the address splits into tag, index and offset. Replacement and write policies decide what happens on a conflict and on a write. The same average-time reasoning extends to multilevel caches (with local and global miss rates), interleaved main memory, memory built from smaller chips, and disk access time. Knowing each formula's exact conditions is what separates a right answer from a near miss: hierarchical vs simultaneous, local vs global miss rate, average vs worst case.

22 previous-year questions · 21 solved · 5 practice questions

Memory Hierarchy and Average Access Time

A computer's memory system is built as a hierarchy: registers, cache, main memory, secondary storage. The reason is that fast memory costs more per bit and cheap memory is slow. A hierarchy works because programs show locality of reference. Temporal locality: a location used now is likely to be used again soon. Spatial locality: locations near it are likely to be used soon. Two quantities describe how well the hierarchy works: the hit ratio and the average access time. The average access time depends on one convention that must be fixed before calculating. Is the lower level accessed only after a cache miss has been detected (hierarchical, or serial, access), or at the same time as the cache (simultaneous, or parallel, access)?

HIT RATIO

The fraction of memory references satisfied directly by the cache. Miss ratio .

AVERAGE ACCESS TIME, HIERARCHICAL (SERIAL) ACCESS

Use this when main memory is accessed only after the cache lookup has missed, so a miss costs . is the time to get the needed data from main memory. If the question says a whole block is transferred into the cache on a miss and gives the block-transfer time, use that time as the miss cost in place of a single-word .

AVERAGE ACCESS TIME, SIMULTANEOUS ACCESS

Use this when the cache and main memory are looked up in parallel. On a miss, the cache-check time is hidden inside the longer memory access and is not added again.

AVERAGE ACCESS TIME FROM A STATED MISS PENALTY

The miss penalty is the EXTRA time a miss costs on top of the hit time. With hierarchical access and , this is the same as the hierarchical formula above.

WORKED EXAMPLE

A cache has ns and main memory has ns. Access is hierarchical (serial), and the hit ratio is . Find the average access time.

Solution
  1. Hierarchical formula: .

  2. ns.

  3. Check with the simplified form: ns.

Answer: 9.0 ns

EXAM TIP

Before using a formula, decide which access model the question describes. Under hierarchical access a miss costs ; under simultaneous access it costs . The two give different answers. In the example above, simultaneous access would give ns, not 9.0 ns. If the question leaves the model open, write down the assumption you used.

Cache Mapping Techniques and Address Structure

A cache holds copies of a small subset of main-memory blocks. Direct-mapped: each memory block maps to exactly one cache line. It is the simplest and needs only one tag comparison, but blocks that map to the same line evict each other (conflict misses). Fully associative: a block may go into any line. There are no conflict misses, but every line's tag must be compared in parallel, which is expensive hardware. Set-associative (-way): the cache is divided into sets of lines each. A block maps to exactly one set but can occupy any of the lines within it. Direct-mapped and fully associative are the special cases and .

Splitting a physical address into tag / index / offset

  1. Offset (block-offset) bits . They select a byte within a block (byte-addressable memory assumed).

  2. Number of sets , where is the associativity.

  3. Index bits . They select the set a block maps to. For a direct-mapped cache, sets = lines. A fully associative cache has zero index bits.

  4. Tag bits . The tag identifies which of the many blocks that map to that set is currently stored there.

  5. Block number . Set (or line) number .

Property

Direct-mapped

Set-associative (-way)

Fully associative

Where a block can go

Exactly 1 line

Exactly 1 set, any of its lines

Any line

Index bits

0

Conflict misses (same cache size)

Typically the most

Typically fewer as grows

None (only compulsory and capacity)

Tag comparators needed

1

(plus a -to-1 multiplexer)

One per line

Hit time (same cache size)

Typically lowest

In between

Typically highest

SIZE OF THE TAG DIRECTORY

Number of lines cache size block size, whatever the associativity. The extra bits per line are whatever the question specifies. Typically that is a valid bit, a dirty bit for a write-back cache, and any replacement bits.

WORKED EXAMPLE

A cache is 256 KB, 4-way set-associative, with a 64-byte block, on a system with a 36-bit physical address (). Find the tag, index and offset field widths.

Solution
  1. Offset bits.

  2. Number of sets , so index bits.

  3. Tag bits.

Answer: Tag = 20 bits, Index = 10 bits, Offset = 6 bits

WORKED EXAMPLE

A 32 KB, 4-way set-associative write-back cache has 32-byte blocks. The physical address is 32 bits (). Each line stores its tag, one valid bit and one dirty bit. Find the total size of the tag memory in bits.

Solution
  1. Offset bits.

  2. Number of lines . Number of sets , so index bits.

  3. Tag bits.

  4. Tag memory bits.

Answer: 21,504 bits

EXAM TIP

A direct-mapped cache is a 1-way set-associative cache. A fully associative cache is a set-associative cache with only 1 set. The same index and offset formulas cover all three: put , or number of sets .

Replacement and Write Policies

A replacement policy is needed only when a block has more than one possible line to go into, that is, in set-associative and fully associative caches. A direct-mapped cache has no choice to make.

Common replacement policies

  1. LRU (Least Recently Used): evict the line in the set that was accessed longest ago. LRU is a stack algorithm. For the same reference string, a fully associative LRU cache with more lines never has more misses than one with fewer lines. The same holds for adding ways to each set while keeping the same sets.

  2. FIFO (First-In-First-Out): evict the line that has been resident longest, regardless of recent use. It is simple to implement (a pointer per set), but it can show Belady's anomaly: more lines, more misses, for some reference strings.

  3. Random: evict a randomly chosen line in the set. It is the cheapest in hardware.

  4. Optimal: evict the block whose next use is farthest in the future. It gives the fewest possible misses but needs knowledge of future references, so it serves only as a yardstick.

Aspect

Write-through

Write-back

When memory is updated

On every write to the cache

Only when a dirty block is evicted

Needs a dirty bit?

No: a cached block is never newer than memory

Yes: it marks a block as modified

Memory writes

One memory write per CPU write

One block write-back per dirty eviction, however many times the block was written

On eviction

Nothing to write back

Write back the block only if it is dirty

Write-miss policies (combine with the table above)

  1. Write-allocate: on a write miss, the block is first fetched into the cache, then the write is applied to the cached copy. Typically paired with write-back.

  2. No-write-allocate (write-around): on a write miss, the write goes straight to main memory and the block is NOT brought into the cache. Typically paired with write-through.

WORKED EXAMPLE

A fully associative cache has 2 lines and is initially empty. Count the misses under FIFO and under LRU for the block reference string A, B, A, C, A.

Solution
  1. FIFO: A miss; B miss; A hit; C miss, evicting A (the oldest arrival); A miss, evicting B. Total 4 misses.

  2. LRU: A miss; B miss; A hit (A becomes most recent); C miss, evicting B (least recently used); A hit. Total 3 misses.

Answer: FIFO 4 misses, LRU 3 misses

EXAM TIP

The statement "FIFO performs at least as well as LRU on every reference string" is false, and the example above is a counterexample. Separately, FIFO can show Belady's anomaly. LRU, being a stack algorithm, cannot.

Types of Cache Misses and Multilevel Caches

The three Cs of cache misses

  1. Compulsory (cold) miss: the first reference to a block. The block has never been in the cache, so this miss occurs however the cache is organised.

  2. Capacity miss: a miss that would still occur in a fully associative cache of the same size, because the program's working set does not fit. A bigger cache reduces capacity misses.

  3. Conflict miss: a miss that occurs only because the block was evicted by other blocks mapping to the same set, while the cache as a whole had room. Higher associativity reduces conflict misses, and a fully associative cache has none by definition.

AVERAGE MEMORY ACCESS TIME, TWO-LEVEL CACHE

Model: L2 is accessed only on an L1 miss, and main memory only on an L2 miss, with each lower-level time added on top (hierarchical). here is the LOCAL miss rate of L2: misses in L2 accesses that reach L2 (the L1 misses). It is not the global miss rate.

GLOBAL MISS RATE OF L2

The fraction of ALL CPU accesses that miss in both L1 and L2 and go to main memory. If a question gives a global L2 miss rate, divide it by to get the local rate before using the AMAT formula.

TWO-LEVEL AVERAGE ACCESS TIME, WRITTEN LEVEL BY LEVEL

The same hierarchical model, with the L1 hit ratio and the LOCAL L2 hit ratio. Expanding gives , which is the AMAT formula above.

WORKED EXAMPLE

L1: hit time 1 ns, local miss rate 10%. L2: hit time 8 ns, local miss rate 20%. Main memory: 150 ns. Access is hierarchical at each level. Find the AMAT and the global miss rate of L2.

Solution
  1. .

  2. ns.

  3. Global miss rate of L2 , so 2% of all accesses reach main memory.

Answer: AMAT = 4.8 ns; global L2 miss rate = 2%

EXAM TIP

Higher associativity reduces conflict misses but tends to raise hit time (more tag comparisons and a wider multiplexer). A bigger cache reduces capacity misses but not compulsory misses. A larger block size reduces compulsory misses by exploiting spatial locality. With a fixed cache size, though, it means fewer blocks, and a larger block also raises the miss penalty.

Main Memory: Building It from Chips, and Interleaving

CHIPS NEEDED TO BUILD AN M X W MEMORY FROM M X B CHIPS

Here and are numbers of words, and and are bits per word. Each row places chips side by side to form the full word width. rows are stacked to supply all the words. The memory needs address lines. Each chip takes the low of them, and the remaining high-order bits drive a decoder that selects one row.

WORKED EXAMPLE

A memory is to be built from chips (). How many chips are needed, how many address lines does the memory have, and how are they used?

Solution
  1. Chips : 4 rows of 2 chips.

  2. Address lines .

  3. Each chip needs lines. The remaining high-order bits go to a 2-to-4 decoder that selects one of the 4 rows.

Answer: 8 chips; 16 address lines (14 to every chip, 2 to a 2-to-4 decoder)

Main memory can be built from several independent banks (modules), so that several word accesses overlap instead of happening one after another. In low-order interleaving, consecutive addresses go to different banks: the bank number is given by the low-order address bits. This suits fetching a sequential block such as a cache line, because the words sit in different banks and can be accessed together. In high-order interleaving, consecutive addresses stay in the same bank: the bank number is given by the high-order address bits. This lets independent accesses to different address regions proceed in different banks, but it gives no speedup for a single sequential block.

TIME TO FETCH AN N-WORD BLOCK FROM LOW-ORDER INTERLEAVED MEMORY WITH M >= N BANKS

Model: all banks start their access together. The first word is on the bus after (the bank access time, including placing the word on the bus). Each further word, already read in its own bank, needs only one bus transfer time . Questions may define the timing differently, for example with a separate address-send cycle. Use the question's model when it gives one.

TIME TO FETCH AN N-WORD BLOCK, NO INTERLEAVING

Same model with a single bank: each word is a full, separate access. This is the baseline against which the speedup from interleaving is measured.

WORKED EXAMPLE

Memory is organised as 4 low-order interleaved banks, each with an access time of 80 ns; the bus transfer time per word is 10 ns. Using the model above, find the time to fetch a 4-word block, with and without interleaving.

Solution
  1. Interleaved: ns.

  2. Non-interleaved: ns.

Answer: 110 ns interleaved vs 320 ns non-interleaved

EXAM TIP

The interleaved formula assumes each bank is used at most once per block (). If the block has more words than there are banks, some banks are used twice. A bank's second access cannot start until its first access cycle ends, so work the timing out from the question's model rather than applying this formula.

Disk Access Time

Disks sit below main memory in the hierarchy and are far slower, because an access involves mechanical motion. The time to access data on a disk is the sum of a few separate components.

DISK ACCESS TIME

Seek: moving the head to the correct track. Rotational latency: waiting for the target sector to rotate under the head. Transfer: reading or writing the data once positioned. Add a controller overhead only if the question gives one. Unless stated otherwise, a given seek time is taken as the average seek time.

AVERAGE ROTATIONAL LATENCY

Half the time of one revolution, in seconds (RPM = revolutions per minute). This is the AVERAGE. The worst case is a full revolution and the best case is zero.

DATA TRANSFER TIME

One track passes under the head per revolution, so the transfer rate is the track capacity times the revolutions per second. Equivalently, reading one sector takes (revolution time) (sectors per track).

WORKED EXAMPLE

A disk spins at 7200 RPM, has an average seek time of 6 ms, and each track holds 200 sectors of 512 bytes. Find the average time to read one sector (no controller overhead).

Solution
  1. Revolution time ms.

  2. Average rotational latency ms.

  3. Transfer time for 1 of 200 sectors on the track ms.

  4. Total ms.

Answer: ≈ 10.21 ms

EXAM TIP

Use the average rotational latency (half a revolution) unless the question asks for the worst case (a full revolution). Convert RPM to revolutions per second before computing a transfer rate.

PREVIOUS-YEAR QUESTIONS

22 questions from the CS papers

Try each question first, then open the answer. One shows the official answer only. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE CSE 2026 Set 1 · GATE CSE 2026 Set 2 · GATE CSE 2025 Set 1 · GATE CSE 2025 Set 2 · GATE CSE 2024 Set 1 · GATE CSE 2024 Set 2 · GATE CSE 2023 · GATE CSE 2022 · GATE CSE 2020 · GATE CSE 2018

GATE 2026 CS1 Q.38

GATE 2026 · CS1Q.38 · 2 marks · MCQ

The size of the physical address space of a processor is bytes. The capacity of a cache memory unit is bytes. The cache block size is 128 bytes. The cache memory unit can be built as a direct mapped cache or as a -way set-associative cache, where and . Let the length of the TAG field be bits for the direct mapped cache, and bits for the set-associative cache.

Which one of the following options is true?

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution
See the question in the paper
GATE 2026 CS1 Q.38: answer and solution

GATE 2026 CS1 Q.54

GATE 2026 · CS1Q.54 · 2 marks · MSQ

Consider a system that has a cache memory unit and a memory management unit (MMU). The address input to the cache memory is a physical address. The MMU has a translation lookaside buffer (TLB). Assume that when a page is evicted from the main memory, the corresponding blocks in the cache are marked as invalid.

For a given memory reference, which of the following sequences of events can NEVER happen?

  1. (A)

    TLB miss, Page table hit, Cache hit

  2. (B)

    TLB hit, Page table miss, Cache hit

  3. (C)

    TLB miss, Page table miss, Cache hit

  4. (D)

    TLB miss, Page table miss, Cache miss

Official answer
See the question in the paper
GATE 2026 CS1 Q.54: official answer

GATE 2026 CS2 Q.52

GATE 2026 · CS2Q.52 · 2 marks · MSQ

Consider a system with a processor and a 4 KB direct mapped cache with block size of 16 bytes. The system has a 16 MB physical memory. Four words P, Q, R, and S are accessed by the processor in the same order 10 times. That is, there are a total of 40 memory references in the sequence P, Q, R, S, P, Q, R, S, …

Assume that the cache memory is initially empty. The physical addresses of the words are given below (1 word = 1 byte).

P: 0x845B32, Q: 0x845B26, R: 0x845B36, S: 0x846B32

Which of the following statements is/are true?

Note: 1K= and 1M=

  1. (A)

    Every access to P results in a cache miss

  2. (B)

    Every access to R results in a cache hit

  3. (C)

    Every access to Q results in a cache miss

  4. (D)

    Except the first access to S, all subsequent accesses to S result in cache hits

Answer and solution
See the question in the paper
GATE 2026 CS2 Q.52: answer and solution

GATE 2026 CS2 Q.56

GATE 2026 · CS2Q.56 · 2 marks · NAT

Consider a system with 1 MB physical memory and a word length of 1 byte. The system uses a direct mapped cache, with block numbers starting from 0. The word with physical address 0xA2C28 is mapped to the cache block number . The maximum possible size of the cache (in KB) for this configuration is ____________. (answer in integer)

Note: and .

Answer and solution
See the question in the paper
GATE 2026 CS2 Q.56: answer and solution

GATE 2025 CS1 Q.36

GATE 2025 · CS1Q.36 · 2 marks · MCQ

Consider a memory system with 1M bytes of main memory and 16K bytes of cache memory. Assume that the processor generates 20-bit memory address, and the cache block size is 16 bytes. If the cache uses direct mapping, how many bits will be required to store all the tag values? [Assume memory is byte addressable, 1K=, 1M=.]

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution
See the question in the paper
GATE 2025 CS1 Q.36: answer and solution

GATE 2025 CS1 Q.53

GATE 2025 · CS1Q.53 · 2 marks · NAT

A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are shown in the figure. The average memory access time in nanoseconds (ns) is ________. (rounded off to two decimal places)

GATE 2025 CS1 question 53: A top-down flowchart: Processor → L1 cache (Hit rate = 95%, Access time = 10 ns) → L2 cache (Hit rate = 85%, Access time…Tap to open full size
Figure from the GATE 2025 CS1 paper. It is part of the question.
Figure description

A top-down flowchart: Processor → L1 cache (Hit rate = 95%, Access time = 10 ns) → L2 cache (Hit rate = 85%, Access time including L1 cache miss penalty = 20 ns) → Main Memory (Access time including L1 and L2 cache miss penalty = 200 ns). Each stage is a box connected by a downward arrow to the next, indicating the access path on a miss at the previous level.

Answer and solution
GATE 2025 CS1 Q.53: answer and solution

GATE 2025 CS2 Q.39

GATE 2025 · CS2Q.39 · 2 marks · MCQ

For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are used to index into a cache block. The size of each cache block is one byte. Assume that there is no other information stored for each cache block.

Which ONE of the following is the CORRECT option for the sizes of the main memory and the cache memory in this system (byte addressable), respectively?

  1. (A)

    64 KB and 4 KB

  2. (B)

    128 KB and 16 KB

  3. (C)

    64 KB and 8 KB

  4. (D)

    128 KB and 6 KB

Answer and solution
See the question in the paper
GATE 2025 CS2 Q.39: answer and solution

GATE 2025 CS2 Q.55

GATE 2025 · CS2Q.55 · 2 marks · NAT

Given a computing system with two levels of cache (L1 and L2) and a main memory. The first level (L1) cache access time is 1 nanosecond (ns) and the "hit rate" for L1 cache is 90% while the processor is accessing the data from L1 cache. Whereas, for the second level (L2) cache, the "hit rate" is 80% and the "miss penalty" for transferring data from L2 cache to L1 cache is 10 ns. The "miss penalty" for the data to be transferred from main memory to L2 cache is 100 ns.

Then the average memory access time in this system in nanoseconds is __________ . (rounded off to one decimal place)

Answer and solution
See the question in the paper
GATE 2025 CS2 Q.55: answer and solution

GATE 2024 CS1 Q.53

GATE 2024 · CS1Q.53 · 2 marks · MSQ

Consider two set-associative cache memory architectures: WBC, which uses the write back policy, and WTC, which uses the write through policy. Both of them use the LRU (Least Recently Used) block replacement policy. The cache memory is connected to the main memory. Which of the following statements is/are TRUE?

  1. (A)

    A read miss in WBC never evicts a dirty block

  2. (B)

    A read miss in WTC never triggers a write back operation of a cache block to main memory

  3. (C)

    A write hit in WBC can modify the value of the dirty bit of a cache block

  4. (D)

    A write miss in WTC always writes the victim cache block to main memory before loading the missed block into the cache

Answer and solution
See the question in the paper
GATE 2024 CS1 Q.53: answer and solution

GATE 2024 CS1 Q.56

GATE 2024 · CS1Q.56 · 2 marks · NAT

A given program has 25% load/store instructions. Suppose the ideal CPI (cycles per instruction) without any memory stalls is 2. The program exhibits 2% miss rate on instruction cache and 8% miss rate on data cache. The miss penalty is 100 cycles. The speedup (rounded off to two decimal places) achieved with a perfect cache (i.e., with NO data or instruction cache misses) is _______

Answer and solution
See the question in the paper
GATE 2024 CS1 Q.56: answer and solution

GATE 2024 CS2 Q.53

GATE 2024 · CS2Q.53 · 2 marks · NAT

Consider a disk with the following specifications: rotation speed of 6000 RPM, average seek time of 5 milliseconds, 500 sectors/track, 512-byte sectors. A file has content stored in 3000 sectors located randomly on the disk. Assuming average rotational latency, the total time (in seconds, rounded off to 2 decimal places) to read the entire file from the disk is ________

Answer and solution
See the question in the paper
GATE 2024 CS2 Q.53: answer and solution

GATE 2023 CS Q.42

GATE 2023 · CSQ.42 · 2 marks · MCQ

A 4 kilobyte (KB) byte-addressable memory is realized using four 1 KB memory blocks. Two input address lines (IA4 and IA3) are connected to the chip select (CS) port of these memory blocks through a decoder as shown in the figure. The remaining ten input address lines from IA11–IA0 are connected to the address port of these blocks. The chip select (CS) is active high.

The input memory addresses (IA11–IA0), in decimal, for the starting locations (Addr=0) of each block (indicated as X1, X2, X3, X4 in the figure) are among the options given below. Which one of the following options is CORRECT?

GATE 2023 CS question 42: 12 address lines IA11 (MSB) down to IA0 (LSB) enter from the left.Tap to open full size
Figure from the GATE 2023 CS paper. It is part of the question.
Figure description

12 address lines IA11 (MSB) down to IA0 (LSB) enter from the left. The upper 10 lines actually used for addressing (all lines except IA4 and IA3) are bundled as a 10-bit bus labelled '10-bit' and fed to the 'Addr' input port of each of four 1KB memory blocks, labelled (left to right) with data-output/name X1, X2, X3, X4, each also having a CS (chip select) pin. IA4 and IA3 are instead routed down into a 2-to-4 decoder block: inputs A1 = IA4, A0 = IA3; outputs Q0, Q1, Q2, Q3 (top to bottom). Q0 connects to the CS of the first (X1) memory block, Q1 to the CS of the second (X2) block, Q2 to the CS of the third (X3) block, and Q3 to the CS of the fourth (X4) block, each via a horizontal wire running across to that block's CS pin. CS is active-high.

  1. (A)

    (0, 1, 2, 3)

  2. (B)

    (0, 1024, 2048, 3072)

  3. (C)

    (0, 8, 16, 24)

  4. (D)

    (0, 0, 0, 0)

Answer and solution
GATE 2023 CS Q.42: answer and solution

GATE 2022 CS Q.24

GATE 2022 · CSQ.24 · 1 mark · MSQ

Let WB and WT be two set associative cache organizations that use LRU algorithm for cache block replacement. WB is a write back cache and WT is a write through cache. Which of the following statements is/are FALSE?

  1. (A)

    Each cache block in WB and WT has a dirty bit.

  2. (B)

    Every write hit in WB leads to a data transfer from cache to main memory.

  3. (C)

    Eviction of a block from WT will not lead to data transfer from cache to main memory.

  4. (D)

    A read miss in WB will never lead to eviction of a dirty block from WB.

Answer and solution
See the question in the paper
GATE 2022 CS Q.24: answer and solution

GATE 2022 CS Q.33

GATE 2022 · CSQ.33 · 1 mark · NAT

A cache memory that has a hit rate of 0.8 has an access latency 10 ns and miss penalty 100 ns. An optimization is done on the cache to reduce the miss rate. However, the optimization results in an increase of cache access latency to 15 ns, whereas the miss penalty is not affected. The minimum hit rate (rounded off to two decimal places) needed after the optimization such that it should not increase the average memory access time is ____.

Answer and solution
See the question in the paper
GATE 2022 CS Q.33: answer and solution

GATE 2022 CS Q.54

GATE 2022 · CSQ.54 · 2 marks · MSQ

Consider a system with 2 KB direct mapped data cache with a block size of 64 bytes. The system has a physical address space of 64 KB and a word length of 16 bits. During the execution of a program, four data words P, Q, R, and S are accessed in that order 10 times (i.e., PQRSPQRS…). Hence, there are 40 accesses to data cache altogether. Assume that the data cache is initially empty and no other data words are accessed by the program. The addresses of the first bytes of P, Q, R, and S are 0xA248, 0xC28A, 0xCA8A, and 0xA262, respectively. For the execution of the above program, which of the following statements is/are TRUE with respect to the data cache?

  1. (A)

    Every access to S is a hit.

  2. (B)

    Once P is brought to the cache it is never evicted.

  3. (C)

    At the end of the execution only R and S reside in the cache.

  4. (D)

    Every access to R evicts Q from the cache.

Answer and solution
See the question in the paper
GATE 2022 CS Q.54: answer and solution

GATE 2020 CS Q.21

GATE 2020 · CSQ.21 · 1 mark · NAT

A direct mapped cache memory of 1 MB has a block size of 256 bytes. The cache has an access time of 3 ns and a hit rate of 94%. During a cache miss, it takes 20 ns to bring the first word of a block from the main memory, while each subsequent word takes 5 ns. The word size is 64 bits. The average memory access time in ns (round off to 1 decimal place) is ____.

Answer and solution
See the question in the paper
GATE 2020 CS Q.21: answer and solution

GATE 2020 CS Q.30

GATE 2020 · CSQ.30 · 2 marks · MCQ

A computer system with a word length of 32 bits has a 16 MB byte-addressable main memory and a 64 KB, 4-way set associative cache memory with a block size of 256 bytes. Consider the following four physical addresses represented in hexadecimal notation.

Which one of the following is TRUE?

  1. (A)

    A1 and A4 are mapped to different cache sets.

  2. (B)

    A2 and A3 are mapped to the same cache set.

  3. (C)

    A3 and A4 are mapped to the same cache set.

  4. (D)

    A1 and A3 are mapped to the same cache set.

Answer and solution
See the question in the paper
GATE 2020 CS Q.30: answer and solution

GATE 2018 CS Q.23

GATE 2018 · CSQ.23 · 1 mark · NAT

A 32-bit wide main memory unit with a capacity of 1 GB is built using 256M × 4-bit DRAM chips. The number of rows of memory cells in the DRAM chip is . The time taken to perform one refresh operation is 50 nanoseconds. The refresh period is 2 milliseconds. The percentage (rounded to the closest integer) of the time available for performing the memory read/write operations in the main memory unit is ____________.

Answer and solution
See the question in the paper
GATE 2018 CS Q.23: answer and solution

GATE 2018 CS Q.34

GATE 2018 · CSQ.34 · 2 marks · MCQ

The size of the physical address space of a processor is bytes. The word length is bytes. The capacity of cache memory is bytes. The size of each cache block is words. For a -way set-associative cache memory, the length (in number of bits) of the tag field is

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution
See the question in the paper
GATE 2018 CS Q.34: answer and solution

PRACTICE

5 questions to test yourself

PRACTICE 12 marks · NAT

A processor has a cache access time ns and a main memory access time ns. Access is hierarchical: the cache is checked first, and only on a miss is main memory accessed, with added on top of the cache-check time. If the hit ratio is , what is the average access time (in ns)?

Answer and solution

Answer: (accepted range )

  1. Hierarchical access: .

  2. ns.

PRACTICE 21 mark · MCQ

A direct-mapped cache has a total size of 32 KB with a block size of 64 bytes. The main memory address is 32 bits wide and memory is byte-addressable (). How many bits of the address form the TAG field?

  1. (A)

    15

  2. (B)

    17

  3. (C)

    19

  4. (D)

    23

Answer and solution

Answer: (B)

  1. Number of cache lines , so index bits .

  2. Offset bits .

  3. Tag bits .

PRACTICE 32 marks · MSQ

Which of the following statements about cache write policies and replacement are TRUE? (Select all that apply.)

  1. (A)

    In a write-back cache with write-allocate, a write MISS first brings the block into the cache before the write is applied.

  2. (B)

    In a write-through cache, every write to the cache also updates main memory, so a cached block is never newer than memory and no dirty bit is needed.

  3. (C)

    A write-back cache can reduce memory traffic compared to write-through when the same cache block is written to several times before it is evicted.

  4. (D)

    The FIFO block-replacement policy performs at least as well as LRU for every possible reference string.

Answer and solution

Answer: (A), (B), (C)

  1. (A) True: write-allocate means a write miss first fetches the block into the cache, then the write is applied to the cached copy.

  2. (B) True: under write-through, every write also goes to memory, so a cached block is never ahead of memory. A dirty bit marks blocks that are ahead of memory, which cannot happen here.

  3. (C) True: write-back writes a block to memory only when it is evicted, so several writes to the same block cost one write-back instead of one memory write each.

  4. (D) False: counterexample with a 2-line fully associative cache and the string A, B, A, C, A. FIFO: A miss, B miss, A hit, C miss (evicts A), A miss, giving 4 misses. LRU: A miss, B miss, A hit, C miss (evicts B), A hit, giving 3 misses.

PRACTICE 42 marks · NAT

A system has a two-level cache. L2 is looked up only on an L1 miss, and main memory only on an L2 miss; each lower-level time is added on top of the time already spent. L1 hit time = 2 ns, L1 local miss rate = 8%. L2 hit (access) time = 15 ns, L2 local miss rate = 25%. Main memory access time = 200 ns. Compute the average memory access time (AMAT), in ns.

Answer and solution

Answer: (accepted range )

  1. AMAT .

  2. ns.

PRACTICE 51 mark · MCQ

A disk rotates at 6000 RPM. What is its average rotational latency?

  1. (A)

    5 ms

  2. (B)

    10 ms

  3. (C)

    2.5 ms

  4. (D)

    20 ms

Answer and solution

Answer: (A)

  1. Time for one full revolution ms.

  2. Average rotational latency half a revolution ms.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE CS

Memory interfacing and hierarchy: performance, cache memory mapping

Preparing in Kolkata? IAE Academy's course for GATE CSE.