Set the thread state of the newly chosen to run thread to TDS_RUNNING in
choosethread() in MI C code instead of doing it in in assembly in all the various cpu_switch() functions. This fixes problems on ia64 and sparc64. Reviewed by: julian, peter, benno Tested on: i386, alpha, sparc64
This commit is contained in:
parent
ed7e4d6c5b
commit
91bb8201ee
@ -80,8 +80,6 @@ ASSYM(MTX_UNOWNED, MTX_UNOWNED);
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
|
||||
ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));
|
||||
|
||||
|
@ -127,9 +127,6 @@ Lcs1: LDGP(pv)
|
||||
mov v0, s2 /* s2 = new thread */
|
||||
ldq s3, TD_MD_PCBPADDR(s2) /* s3 = new pcbpaddr */
|
||||
|
||||
ldiq t0, TDS_RUNNING
|
||||
stl t0, TD_STATE(s2)
|
||||
|
||||
/*
|
||||
* Check to see if we're switching to ourself. If we are,
|
||||
* don't bother loading the new context.
|
||||
|
@ -171,13 +171,6 @@ sw1:
|
||||
|
||||
sw1b:
|
||||
movl %eax,%ecx
|
||||
|
||||
#ifdef INVARIANTS
|
||||
cmpb $TDS_RUNQ,TD_STATE(%ecx)
|
||||
jne badsw2
|
||||
#endif
|
||||
|
||||
movl $TDS_RUNNING,TD_STATE(%ecx)
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
@ -316,13 +309,6 @@ cpu_switch_load_gs:
|
||||
ret
|
||||
|
||||
#ifdef INVARIANTS
|
||||
badsw2:
|
||||
pushal
|
||||
pushl $sw0_2
|
||||
call panic
|
||||
|
||||
sw0_2: .asciz "cpu_switch: not TDS_RUNQ"
|
||||
|
||||
badsw3:
|
||||
pushal
|
||||
pushl $sw0_3
|
||||
|
@ -82,7 +82,6 @@ ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
|
||||
ASSYM(P_STATE, offsetof(struct proc, p_state));
|
||||
ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
|
||||
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
|
||||
ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
@ -100,9 +99,6 @@ ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));
|
||||
ASSYM(KEF_ASTPENDING, KEF_ASTPENDING);
|
||||
ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED);
|
||||
|
||||
ASSYM(TDS_SLP, TDS_SLP);
|
||||
ASSYM(TDS_RUNQ, TDS_RUNQ);
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
|
||||
ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
|
||||
ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
|
||||
|
@ -171,13 +171,6 @@ sw1:
|
||||
|
||||
sw1b:
|
||||
movl %eax,%ecx
|
||||
|
||||
#ifdef INVARIANTS
|
||||
cmpb $TDS_RUNQ,TD_STATE(%ecx)
|
||||
jne badsw2
|
||||
#endif
|
||||
|
||||
movl $TDS_RUNNING,TD_STATE(%ecx)
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
@ -316,13 +309,6 @@ cpu_switch_load_gs:
|
||||
ret
|
||||
|
||||
#ifdef INVARIANTS
|
||||
badsw2:
|
||||
pushal
|
||||
pushl $sw0_2
|
||||
call panic
|
||||
|
||||
sw0_2: .asciz "cpu_switch: not TDS_RUNQ"
|
||||
|
||||
badsw3:
|
||||
pushal
|
||||
pushl $sw0_3
|
||||
|
@ -82,7 +82,6 @@ ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
|
||||
ASSYM(P_STATE, offsetof(struct proc, p_state));
|
||||
ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
|
||||
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
|
||||
ASSYM(TD_WCHAN, offsetof(struct thread, td_wchan));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
@ -100,9 +99,6 @@ ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));
|
||||
ASSYM(KEF_ASTPENDING, KEF_ASTPENDING);
|
||||
ASSYM(KEF_NEEDRESCHED, KEF_NEEDRESCHED);
|
||||
|
||||
ASSYM(TDS_SLP, TDS_SLP);
|
||||
ASSYM(TDS_RUNQ, TDS_RUNQ);
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
|
||||
ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
|
||||
ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
|
||||
|
@ -171,13 +171,6 @@ sw1:
|
||||
|
||||
sw1b:
|
||||
movl %eax,%ecx
|
||||
|
||||
#ifdef INVARIANTS
|
||||
cmpb $TDS_RUNQ,TD_STATE(%ecx)
|
||||
jne badsw2
|
||||
#endif
|
||||
|
||||
movl $TDS_RUNNING,TD_STATE(%ecx)
|
||||
movl TD_PCB(%ecx),%edx
|
||||
|
||||
#if defined(SWTCH_OPTIM_STATS)
|
||||
@ -316,13 +309,6 @@ cpu_switch_load_gs:
|
||||
ret
|
||||
|
||||
#ifdef INVARIANTS
|
||||
badsw2:
|
||||
pushal
|
||||
pushl $sw0_2
|
||||
call panic
|
||||
|
||||
sw0_2: .asciz "cpu_switch: not TDS_RUNQ"
|
||||
|
||||
badsw3:
|
||||
pushal
|
||||
pushl $sw0_3
|
||||
|
@ -76,11 +76,9 @@ ASSYM(MTX_UNOWNED, MTX_UNOWNED);
|
||||
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack));
|
||||
ASSYM(TD_MD_FLAGS, offsetof(struct thread, td_md.md_flags));
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
|
||||
ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));
|
||||
|
||||
|
@ -283,12 +283,6 @@ ENTRY(cpu_switch, 0)
|
||||
st8 [r14]=r4 // set r13->pc_curthread
|
||||
mov ar.k7=r4
|
||||
;;
|
||||
// Julian's guess at settinghte thread state
|
||||
add r15=TD_STATE,r4
|
||||
;;
|
||||
mov [r15]=TDS_RUNNING
|
||||
;;
|
||||
// end of julian's guess
|
||||
add r15=TD_PCB,r4
|
||||
;;
|
||||
ld8 r15=[r15]
|
||||
|
@ -155,11 +155,10 @@ choosethread(void)
|
||||
} else {
|
||||
/* Pretend the idle thread was on the run queue. */
|
||||
td = PCPU_GET(idlethread);
|
||||
/* Simulate that it was on the run queue */
|
||||
td->td_state = TDS_RUNQ;
|
||||
td->td_kse->ke_state = KES_UNQUEUED;
|
||||
CTR1(KTR_RUNQ, "choosethread: td=%p (idle)", td);
|
||||
}
|
||||
td->td_state = TDS_RUNNING;
|
||||
return (td);
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,6 @@ ENTRY(cpu_switch)
|
||||
|
||||
/* thread to restore is in r3 */
|
||||
.L2:
|
||||
li %r15,TDS_RUNNING
|
||||
stw %r15,TD_STATE(%r3) /* Set KSE state */
|
||||
lwz %r3, TD_PCB(%r3)
|
||||
lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
|
||||
mr %r2,%r12
|
||||
|
@ -140,8 +140,6 @@ ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
|
||||
ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
|
||||
|
||||
|
@ -121,8 +121,6 @@ ENTRY(cpu_switch)
|
||||
|
||||
/* thread to restore is in r3 */
|
||||
.L2:
|
||||
li %r15,TDS_RUNNING
|
||||
stw %r15,TD_STATE(%r3) /* Set KSE state */
|
||||
lwz %r3, TD_PCB(%r3)
|
||||
lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
|
||||
mr %r2,%r12
|
||||
|
@ -121,8 +121,6 @@ ENTRY(cpu_switch)
|
||||
|
||||
/* thread to restore is in r3 */
|
||||
.L2:
|
||||
li %r15,TDS_RUNNING
|
||||
stw %r15,TD_STATE(%r3) /* Set KSE state */
|
||||
lwz %r3, TD_PCB(%r3)
|
||||
lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */
|
||||
mr %r2,%r12
|
||||
|
@ -232,8 +232,6 @@ ASSYM(TD_KSE, offsetof(struct thread, td_kse));
|
||||
ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack));
|
||||
ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
|
||||
ASSYM(TD_PROC, offsetof(struct thread, td_proc));
|
||||
ASSYM(TD_STATE, offsetof(struct thread, td_state));
|
||||
ASSYM(TDS_RUNNING, TDS_RUNNING);
|
||||
|
||||
ASSYM(PCB_SIZEOF, sizeof(struct pcb));
|
||||
ASSYM(PCB_FPSTATE, offsetof(struct pcb, pcb_fpstate));
|
||||
|
@ -109,9 +109,6 @@ ENTRY(cpu_switch)
|
||||
stx %o0, [PCPU(CURTHREAD)]
|
||||
stx %o1, [PCPU(CURPCB)]
|
||||
|
||||
mov TDS_RUNNING, %o2
|
||||
stw %o2, [%o0 + TD_STATE]
|
||||
|
||||
SET(sched_lock, %o3, %o2)
|
||||
stx %o0, [%o2 + MTX_LOCK]
|
||||
|
||||
|
@ -109,9 +109,6 @@ ENTRY(cpu_switch)
|
||||
stx %o0, [PCPU(CURTHREAD)]
|
||||
stx %o1, [PCPU(CURPCB)]
|
||||
|
||||
mov TDS_RUNNING, %o2
|
||||
stw %o2, [%o0 + TD_STATE]
|
||||
|
||||
SET(sched_lock, %o3, %o2)
|
||||
stx %o0, [%o2 + MTX_LOCK]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user