We need this to make SIGSTOP work reliably and properly
; Mark outselves as idle
;
ldx U_DATA__U_PTAB
+ lda a:P_TAB__P_STATUS_OFFSET,x
+ cmp #P_RUNNING
+ bne not_running
lda #P_READY
sta a:P_TAB__P_STATUS_OFFSET,x
+not_running:
;
; Drop back to a8i8 and schedule ourself out
;
;
ldx U_DATA__U_PTAB
; Move to ready state
+ lda P_TAB__P_STATUS_OFFSET,x
+ cmpa #P_RUNNING
+ bne not_running
lda #P_READY
sta P_TAB__P_STATUS_OFFSET,x
+not_running:
; Sleep on the kernel stack, IRQs will get re-enabled if need
; be
jsr _platform_switchout
lds #kstack_top
jsr chksigs
ldx U_DATA__U_PTAB
+ ldab P_TAB__P_STATUS_OFFSET,x
+ cmpb #P_RUNNING
+ bne not_running
ldab #P_READY
stab P_TAB__P_STATUS_OFFSET,x
+not_running:
jsr platform_switchout
jsr map_process_always
; caller will switch back to stack in X
; Process status is offset 0
;
ld hl, (U_DATA__U_PTAB)
+ ld a, #P_RUNNING
+ cp (hl)
+ jr nz, not_running
ld (hl), #P_READY
+not_running:
call _platform_switchout
;
; We are no longer in an interrupt or a syscall
ld (U_DATA__U_INSYS),a
call _chksigs
ld hl, (U_DATA__U_PTAB)
+ ld a,#P_RUNNING
+ cp (hl)
+ jr nz, not_running
ld (hl), #P_READY
+not_running:
; Give up the CPU
; FIXME: can we get here on timers when only one thing is running
; and we don't need to pre-empt ????? Is this more generally busted
; Process status is offset 0
;
ld hl, (U_DATA__U_PTAB)
+ ld a,#P_RUNNING
+ cp (hl)
+ jr nz, not_running
ld (hl), #P_READY
+not_running:
call _platform_switchout
;
; We are no longer in an interrupt or a syscall