In practice, many operating systems are designed to have one kernel stack for each thread, or at least one for each CPU. But for an operating system that the kernel is locked every time a process traps, it seems unnecessary to have separated kernel stacks for each CPU. Since the kernel (with its own stack) only allows single CPU access, the CPUs should never be in kernel mode simultaneously. A CPU is always blocked until the previous CPU leaves and cleans up the kernel stack, even in the nested trap case. So in which case will multiple kernel stack be necessary in such an OS? Thanks.
You're right; in such a case multiple kernel stacks wouldn't be useful as long as you have a solid multi-core locking feature.
We usually have multiple kernel stacks (i.e. at least one kernel stack for each thread) for the following purposes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With