From: Alan Cox Date: Mon, 21 Jan 2019 22:19:23 +0000 (+0000) Subject: preemption: allow pre-emption where the leaving processis marked STOPPED X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ea75fb6732f27d02985c52d5eebcf956b7e0da59;p=FUZIX.git preemption: allow pre-emption where the leaving processis marked STOPPED We need this to make SIGSTOP work reliably and properly --- diff --git a/Kernel/lowlevel-65c816.s b/Kernel/lowlevel-65c816.s index 397fa325..4f26b3ee 100644 --- a/Kernel/lowlevel-65c816.s +++ b/Kernel/lowlevel-65c816.s @@ -634,8 +634,12 @@ ret_to_user: ; 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 ; diff --git a/Kernel/lowlevel-6809.s b/Kernel/lowlevel-6809.s index 21d5e6c7..75ef71d8 100644 --- a/Kernel/lowlevel-6809.s +++ b/Kernel/lowlevel-6809.s @@ -249,8 +249,12 @@ in_kernel: ; 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 diff --git a/Kernel/lowlevel-68hc11.s b/Kernel/lowlevel-68hc11.s index 01838154..83568529 100644 --- a/Kernel/lowlevel-68hc11.s +++ b/Kernel/lowlevel-68hc11.s @@ -149,8 +149,12 @@ interrupt_handler: 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 diff --git a/Kernel/lowlevel-z80-banked.s b/Kernel/lowlevel-z80-banked.s index f6ad820d..d7b5a7f2 100644 --- a/Kernel/lowlevel-z80-banked.s +++ b/Kernel/lowlevel-z80-banked.s @@ -548,7 +548,11 @@ intret2:di ; 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 diff --git a/Kernel/lowlevel-z80-thunked.s b/Kernel/lowlevel-z80-thunked.s index 4ebdff65..bd464885 100644 --- a/Kernel/lowlevel-z80-thunked.s +++ b/Kernel/lowlevel-z80-thunked.s @@ -304,7 +304,11 @@ intret2: 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 diff --git a/Kernel/lowlevel-z80.s b/Kernel/lowlevel-z80.s index db6476f1..c2bc78ff 100644 --- a/Kernel/lowlevel-z80.s +++ b/Kernel/lowlevel-z80.s @@ -567,7 +567,11 @@ intret2:call map_kernel_di ; 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