9 lines
1.4 KiB
HTML
9 lines
1.4 KiB
HTML
<!doctype html><html lang="en"><meta charset="utf-8"><title>A scheduler with observable order</title><h1>A scheduler with observable order</h1><p>15-minute session: read for 3 minutes, trace for 3, experiment for 7, and complete the check for 2. Spend longer whenever you need.</p><p>A scheduler chooses which runnable task receives a turn. Model round-robin with a queue. Each task consumes one unit before returning to the queue if work remains. This deterministic model omits interrupts, context switching, and true parallel execution.</p><p><strong>Practice and evidence:</strong> Trace A=2 and B=1, then add an empty task and document whether it should enter the runnable queue. Test fairness by checking the execution order.</p><pre><code class="language-python">from collections import deque
|
|
ready=deque([("A",2),("B",1)])
|
|
order=[]
|
|
while ready:
|
|
name,left=ready.popleft()
|
|
order.append(name)
|
|
if left>1: ready.append((name,left-1))
|
|
print(" ".join(order))
|
|
</code></pre><p><strong>Expected result:</strong> <code>A B A</code></p><h3>Practice and evidence</h3><p>Keep three notes: your prediction, the actual result, and why they match or differ. The completion check grades understanding; the practice task builds skill.</p><p><a href="https://git.agilaos.com/matt/open_kernel">Language reference: git.agilaos.com</a></p><p><a href="https://git.agilaos.com/matt/agila_open_tool">Language reference: git.agilaos.com</a></p></html> |