aboutsummaryrefslogtreecommitdiffstats
path: root/src/sched.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/sched.asm')
-rw-r--r--src/sched.asm12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sched.asm b/src/sched.asm
index c871f7a..a540c49 100644
--- a/src/sched.asm
+++ b/src/sched.asm
@@ -31,13 +31,14 @@ SchedRunFirst::
; caller when this task is eventually rescheduled.
; -----------------------------------------------------------------------------
SchedYield::
- call FindNextReady ; DE = &next PCB
+ call FindNextReady ; DE = &next PCB, CF if none runnable
+ ret c ; nobody else ready: keep running current
call hSwitchTo
ret
; -----------------------------------------------------------------------------
-; FindNextReady - round-robin from wSchedNext. out: DE = &PCB (updates cursor)
-; Scaffold: assumes at least one PS_READY task exists.
+; FindNextReady - round-robin from wSchedNext.
+; out: DE = &PCB and CF clear on success; CF set if nothing is PS_READY.
; -----------------------------------------------------------------------------
FindNextReady::
ld a, [wSchedNext]
@@ -56,14 +57,13 @@ FindNextReady::
pop af ; restore candidate slot
dec b
jr nz, .scan
- ; nothing ready: fall back to slot 0 (idle behavior)
- xor a
- call PcbPtr
+ scf ; nothing runnable
ret
.found
pop af ; A = chosen slot
ld [wSchedNext], a
call PcbPtr ; DE = &PCB
+ and a ; clear carry
ret
; -----------------------------------------------------------------------------