C8 Computer organization · Practice
Critical sections and atomicity
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 7 kinds solid
Check
A main loop of 6 instructions does a read-modify-write, and a tick arriving before any of 2 of them loses the handler's update. 1000 ticks arrive at random points.
(a)
What fraction of the handler's updates are lost?
(b)
About how many updates are lost?
Check
A 16 MHz core takes 6 cycles to enter a handler, and its longest critical section is 100 cycles.
(a)
What's the worst-case interrupt latency?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
(b)
And with no critical sections?
Check
head (at 0x1000) indexes an 8-word ring buffer buf (from 0x1004). Store a1 at buf[head], then advance head, wrapping from 7 to 0.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
A ring buffer of 16 slots has head = 1 and tail = 7: the head has wrapped around.
(a)
How many entries are waiting?
(b)
How many more can the handler add before it's full?
Check
A 2-instruction window in a 7-instruction loop. What share of ticks lose their update?
Check
16 MHz, 12-cycle entry, 60-cycle critical section. Worst-case latency?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
Ring buffer of 16, head 2, tail 12. Entries waiting?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C8