Messages in this thread | | | From | "Khimenko Victor" <> | Date | Sat, 4 Sep 1999 17:12:21 +0400 (MSD) | Subject | Re: SMP linux help |
| |
In <Pine.LNX.4.10.9909041703160.38395210-100000@csemt83.cse.iitk.ac.in> sushil@iitk.ac.in (sushil@cse.iitk.ac.in) wrote: > Hi, > I am running linux 2.9.9 kernel. > I am trying the understand the locking mechanism used in linux to make > the kernel SMP safe. In do_fork() (also in many other syscall interface > functions) there is call to lock_kernel() function. What does > lock_kernel() do?
lock-kernel is exactly what it says: lock kernel via global kernel lock. Not from other processes on other processes but from processes on the same processor also. It was invented way before Linus even dreamed about SMP...
> If If it is used to synchronize the access to kernel data > structures from other processes on other processors, then why, after > having called this function, we again try to do some locking like calling > spin_lock(&lastpid_lock) in get_pid()?
Since kernel lock is NOT protecting everything. Initially just one kernel lock protected everything in kernel. It was not SMP-friendly. So global kernel lock was replaced by bunch of smaller locks. Some things are still protected by global lock but some things need personal lock (things access for which are time-critical mostly)... It's not trivial change since you need to take care about potential deadlock situations...
> I have seen the definition of lock_kernel. It increments the > current->lock_depth and if it nonzero then tries to lock the kernel_flag > variable.
> Kindly reply. > I am on this mailing list.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |