Practice ยท 1 of 2
Write like the OS is watching
Implement AtomicStore โ a file store whose write(path, data) follows the real atomic-replace pattern, recorded in log:
- append ('write', path + '.tmp'), then ('flush', path + '.tmp'), then ('replace', path + '.tmp', path)
- after the log entries, the data is readable at path, and no .tmp file remains
- read(path) raises FileNotFoundError for unknown paths
- expose log as a property
The log IS the test: a torn write is impossible when the sequence is write-tmp, flush, replace.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Systems Drills