Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Measure external fragmentation

Q297·Free·SystemVerilog

Measure external fragmentation

Difficulty
Easy
Topic
Memory Systems
Language
SV
Interview prompt

Question

Report total free capacity, the largest contiguous free block, and a defined external-fragmentation ratio.

Starting point

Question code

function void fragmentation_metrics(
  output longint unsigned total_free,
  output int unsigned largest_block,
  output real external_ratio
);
Reviewed example

Trace one case

Input
free=[[0,9],[20,24]]
Expected output
total_free=15; largest_block=10; external_ratio=1-10/15=0.3333

Inclusive sizes are 10 and 5, and the largest-to-total fraction is subtracted from one.

What to cover

Requirements

  1. Measure inclusive range sizes correctly.
  2. Return zeros for an empty free list.
  3. Define external_ratio as 1 minus largest_block divided by total_free.
  4. Avoid division by zero.
Exact question handoffPractice Q297

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessA Free account unlocks the complete reviewed solution.
Continue learning

SystemVerilog

  • Memory Systems
  • Allocator
  • Fragmentation
  • Metrics
Interview preparation guide →
Continue practicing

Related questions

Q212 · Memory SystemsBuild a first-fit range allocator→Q276 · Memory SystemsRandomize free-range allocation→Q277 · Memory SystemsCompact live allocations→
ASIC.FYI · Learn silicon end to end.info@asic.fyi