Master the fundamental concepts of storage fundamentals through this focused micro-challenge.
Operating systems and devices prefer I/O sizes and offsets that are multiples of the block size (often 4096). An unaligned range may require reading two blocks, modifying the middle, and writing both back even if the application wanted a few bytes.
Align start down to block boundary, end up to boundary, compute span in blocks.
cLoading…
O_DIRECT bypasses page cache and enforces alignment strictlyKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will compute how many blocks an unaligned range touches versus an aligned range. This exercise asks you to print overhead for sub-page updates.
Write a C program that demonstrates the cost of unaligned I/O.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github