C8 Computer organization · Practice
Privilege modes and system calls
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.
Check
mcause reads 80000007, an interrupt. What is its cause code, with the interrupt bit removed?
Check
A program writes 1 MB in chunks of 64 KB, one system call per chunk. Each call costs 300 cycles of overhead on a 3 GHz processor. How much time is overhead?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A trap handler saves and restores 31 registers of 4 bytes, one memory instruction each, plus 80 cycles of other work. How many cycles does a trap cost at one cycle per memory instruction?
Check
A task makes 20000 system calls a second, each costing 102 cycles of overhead, on a 400 MHz processor. What percentage of the processor does that use?
Check
The starter installs a trap handler and makes a system call. Complete the handler so that it doubles a0 and returns to the instruction after the ecall.
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
Model buffered output. A program emits n = 1000 messages whose lengths are rng.randrange(10, 200) bytes (rng = random.Random(seed)). Write calls_unbuffered(lengths) (one system call per message) and calls_buffered(lengths, B): copy messages into a buffer of B bytes and make one call each time the next message wouldn't fit (and one at the end if anything is left); a message longer than B gets its own call. Set u, b4k (with B = 4096) and ratio = u / b4k.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
What cause code is in mcause = 80000005?
Check
How long do 1000 system calls of 200 cycles take on a 3 GHz processor, in µs?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
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