preemption: allow pre-emption where the leaving processis marked STOPPED
authorAlan Cox <alan@linux.intel.com>
Mon, 21 Jan 2019 22:19:23 +0000 (22:19 +0000)
committerAlan Cox <alan@linux.intel.com>
Mon, 21 Jan 2019 22:19:23 +0000 (22:19 +0000)
We need this to make SIGSTOP work reliably and properly

Kernel/lowlevel-65c816.s
Kernel/lowlevel-6809.s
Kernel/lowlevel-68hc11.s
Kernel/lowlevel-z80-banked.s
Kernel/lowlevel-z80-thunked.s
Kernel/lowlevel-z80.s

index 397fa32..4f26b3e 100644 (file)
@@ -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
        ;
index 21d5e6c..75ef71d 100644 (file)
@@ -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
index 0183815..8356852 100644 (file)
@@ -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
index f6ad820..d7b5a7f 100644 (file)
@@ -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
index 4ebdff6..bd46488 100644 (file)
@@ -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
index db6476f..c2bc78f 100644 (file)
@@ -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