Shutdown sometimes does not work unconditionally


I realized that shutdown command sometimes does not work.
When doing shutdown correctly, below output is displayed, but if not, no output is displayed and I can send other commands via terminal. Also, when doing nothing, exit code is 0.

Main kernel thread exited with status 9
kernel::arch::x86_64::stop:INFO -- Running kstop()
kernel::arch::x86_64::stop:INFO -- Notifying any potential ACPI driver
kernel::arch::x86_64::stop:INFO -- Waiting one second for ACPI driver to run the shutdown sequence.
2022-12-25T08-39-28..754++00:00 [@acpid:207 INFO] Received shutdown request from kernel.
2022-12-25T08-39-28..804++00:00 [@acpid::aml:127 INFO] Shutdown SLP_TYPa 0, SLP_TYPb 0
2022-12-25T08-39-28..829++00:00 [@acpid::aml:132 INFO] Shutdown with ACPI outw(0x604, 0x2000)

By looking into kernel code, I suspect KILL signal is not handled by pid 1(init?).

However, I cannot find why init process does not handle KILL signal because the signal handler should run after context switch, if I understand correctly.

As far as I know, if the process is not runnable, the process is not target of context switch, but I do not know why init is not runnable.

My question is where is init process code. I followed the code until fn usermode_bootstrap in src/scheme/syscall/ from kmain, but I cannot find the entrypoint bootstrap has points to where.

host OS: Linux Ubuntu 22.04
uname -a: Linux SoyaOhnishi 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
guest OS: Redox 0.8.0


After some exploring, I suspect that this problem is qemu specific problem, probablly because this problem is caused by being not able to get semaphore for using context list when switching next context.
As far as I know, this only happens when running on multicore environment.

I do not know why specific core cannot get semaphore, but, probably, this is because of emulation and there is no problem when running on real hardware.

By the way, why is context list shared between cores? Is it for simple implementation?

Maybe it’s related to this:

Open an issue on our GitLab and talk with us on our Matrix Support Room.