S3 · Lesson 37 · Arbiters and shared resources
Fixed priority and round-robin arbitration, fairness, weights and arbiter hardware
Whenever several masters share one bus, memory port or network link, an arbiter decides who goes next, every cycle. The choice of rule sets each master's worst-case latency and its share of bandwidth: a fixed-priority arbiter is tiny but can starve its lowest requester forever, while a round-robin arbiter bounds every wait at the cost of a little state. Real systems mix the two, with weights for bandwidth guarantees and priorities for latency-critical traffic, and the arbiter's own logic depth can end up on the critical path.
- The stems are the fraction of cycles each of 16 requesters wins under fixed priority (requester 0 highest), when each requests independently with probability p in every cycle: requester i wins .
- At low load everyone is served. As p rises, the high-priority requesters take nearly everything and the low ones starve.
- The dashed line is the share round-robin guarantees each when all of them request: 1/16.
Predict
Eight masters share a bus through a round-robin arbiter, and each transfer holds the bus for 4 cycles. A master raises its request just after losing its turn. What is its longest possible wait?
Round-robin passes the grant around in order, so in the worst case the other seven masters each get one 4-cycle transfer first: cycles. That bound holds however busy the others are, which is the point of round-robin. Under fixed priority, the lowest master's wait has no bound at all.
Name it
Fixed priority
Grant the lowest-numbered requester: a priority encoder, levels deep. Simple and fast, but a requester is served only in cycles when every higher one is idle, so under load the lowest can starve.
Round-robin
After granting requester i, the highest priority passes to i + 1. A master waits at most for every other master's turn:
for transfers of T cycles. Hardware: a pointer of bits and either two priority encoders (masked and unmasked requests) or one double-width encoder.
Weighted round-robin
Requester i gets turns per round, a share of the resource when everyone is requesting: bandwidth guarantees for, say, a display controller that must never underflow.
Matrix arbiter
A least-recently-granted arbiter keeps one bit for each pair of requesters saying which has priority over the other, bits, updated so the winner drops below everyone. It's fair and fast but grows quadratically.
Load
If N requesters each want a fraction r of the cycles, the total demand is Nr. Below 1, every requester is served eventually and waits are short; at or above 1 the resource is saturated and the arbitration rule decides who loses.
Worked example
A 1.6 GB/s memory port is shared by weighted round-robin with weights 4, 2, 1 and 1. What bandwidth does each requester get when all are busy?
Show the solution
- Shares. The weights sum to 8, so the shares are 4/8, 2/8, 1/8 and 1/8: 50%, 25%, 12.5% and 12.5%.
- Bandwidth. Of 1.6 GB/s, that's 800, 400, 200 and 200 MB/s.
- Idle requesters. When a requester is idle its turns go to the others, so each share is a guaranteed minimum, and a busy requester can get more.
Answer 800, 400, 200 and 200 MB/s.
Worked example
Under fixed priority, requester 0 asks for the bus in 60% of cycles and requester 1 in 50%, independently. At most what share can requester 2 get?
Show the solution
- When requester 2 wins. Only when both higher requesters are idle: 20% of cycles, however much it needs.
- If it needs more. If it needs 30% it falls further behind every second: it starves without any bug, purely from load.
Answer at most 20% of cycles.
Worked example
How much state does a matrix arbiter need for 8 requesters, against a round-robin pointer? And for 32?
Show the solution
- Eight requesters. A matrix arbiter needs against 3 bits for a round-robin pointer.
- Thirty-two requesters. against 5.
- Where each fits. Matrix arbiters suit small, fast arbiters such as switch ports; wide arbiters use round-robin pointers, often in two levels.
Answer 28 bits against 3 for 8 requesters, and 496 bits against 5 for 32.
Check
8 masters share a resource through a round-robin arbiter; each grant holds it for 1 cycles at 500 MHz.
(a)
What is the longest a master can wait?
(b)
How long is that in time?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
Three requesters share a 3.2 GB/s link by weighted round-robin with weights 2, 1 and 3.
(a)
What share does the first get when all are busy?
(b)
What bandwidth is that?
Check
An arbiter serves 8 requesters.
(a)
How much state does a matrix arbiter need?
(b)
And a round-robin pointer?
Check
Under fixed priority, requesters 0 and 1 ask independently in fractions 0.3 and 0.2 of cycles; requester 2 asks in 0.3.
(a)
At most what share of cycles can requester 2 win?
(b)
What share does it actually win, if its own requests are independent too?
Check
A low-priority DMA engine shares memory with a CPU under fixed priority and sometimes stalls for milliseconds. What change bounds its wait without hurting the CPU's average latency much?
Check
N requesters each want the resource in a fraction r of cycles, and each grant lasts T cycles under round-robin.
Step 1
What is the total demand, as a fraction of the resource?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the worst-case wait?
Step 3
What share does each get when all request continuously?
Check
Write rr_arbiter(requests): requests is a list of per-cycle lists of booleans (one per requester). Each cycle, grant the first requesting index at or after the round-robin pointer (wrapping), then move the pointer just past the winner; return the list of grants (None when nobody requests). The pointer starts at 0.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can a fixed-priority arbiter starve a requester even when the total demand is below the resource's capacity?
Under fixed priority the lowest requester is served only in cycles when every higher requester happens to be idle. If the higher requesters' requests arrive independently, those idle cycles are rarer than the leftover capacity suggests, and if the lowest requester needs more than that fraction, it falls behind steadily. Worse, bursts from the higher requesters can lock it out for long stretches, so its worst-case wait has no bound. A round-robin arbiter passes priority around, so every requester gets a turn at least once per round, which bounds its wait at the other requesters' turns.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.