About Kernel preemption and kernel mode stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

Just had couple of questions:

1. kernel is preemptible if we are running in kernel mode and not holding any lock. What if we preempt the kernel even when we are holding lock? Assuming process A and B are trying to execute the same kernel path. So what if something like this happens:
A gets into kernel mode and acquires a lock and then B comes, we preempt A and schedule B. B gets into kernel mode, tries to acquire the lock but its not available B goes to sleep,  A gets the CPU again goes ahead does its job and releases the lock. B wakes up gets the lock and proceeds normal.
Would there be any problem? I think no. Then why cannot we preempt kernel when we are holding a lock in kernel mode?

2. If kernel is not preemptible then do we really need a separate kernel mode stack for each and every process? I mean cannot we use a common kernel mode stack for all and every process? I think we can because since only one process could be in the kernel mode at a time, any process getting into kernel mode can easily assume that the kernel mode stack is always free whenever it gets into kernel mode.

I know I am wrong somewhere but unable to figure out.

Thanks in advance!

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux