CVSROOT:        /cvs
Module name:    src
Changes by:     clau...@cvs.openbsd.org 2023/10/24 07:20:11

Modified files:
        sys/arch/alpha/alpha: cpu.c locore.s vm_machdep.c 
        sys/arch/amd64/amd64: cpu.c locore.S 
        sys/arch/arm/arm: cpu.c cpuswitch7.S 
        sys/arch/arm64/arm64: cpu.c cpuswitch.S 
        sys/arch/hppa/dev: cpu.c 
        sys/arch/hppa/hppa: locore.S 
        sys/arch/i386/i386: cpu.c locore.s 
        sys/arch/loongson/loongson: machdep.c 
        sys/arch/luna88k/luna88k: machdep.c 
        sys/arch/m88k/m88k: eh_common.S 
        sys/arch/macppc/macppc: cpu.c locore.S machdep.c 
        sys/arch/mips64/mips64: clock.c context.S 
        sys/arch/octeon/octeon: machdep.c 
        sys/arch/powerpc64/powerpc64: cpu.c locore.S 
        sys/arch/riscv64/riscv64: cpu.c cpuswitch.S 
        sys/arch/sh/sh : locore_subr.S vm_machdep.c 
        sys/arch/sparc64/sparc64: cpu.c locore.s 
        sys/kern       : kern_fork.c kern_sched.c 
        sys/sys        : sched.h 

Log message:
Normally context switches happen in mi_switch() but there are 3 cases
where a switch happens outside. Cleanup these code paths and make the
machine independent.

- when a process forks (fork, tfork, kthread), the new proc needs to
somehow be scheduled for the first time. This is done by proc_trampoline.
Since proc_trampoline is machine dependent assembler code change
the MP specific proc_trampoline_mp() to proc_trampoline_mi() and make
sure it is now always called.
- cpu_hatch: when booting APs the code needs to jump to the first proc
running on that CPU. This should be the idle thread for that CPU.
- sched_exit: when a proc exits it needs to switch away from itself and
then instruct the reaper to clean up the rest. This is done by switching
to the idle loop.

Since the last two cases require a context switch to the idle proc factor
out the common code to sched_toidle() and use it in those places.

Tested by many on all archs.
OK miod@ mpi@ cheloha@

Reply via email to