2000-12-23 13:16:38

by Sourav Sen

[permalink] [raw]
Subject: why both kernel lock as well as semaphore


In many parts of the kernel, I have seen both semaphore is taken
(eg. down(&current->mm->mmap_sem)) as well as kernel lock (lock_kernel())
is also taken, why both are required? Whats the purpose of each?

~sourav


2000-12-23 14:35:06

by Tigran Aivazian

[permalink] [raw]
Subject: Re: why both kernel lock as well as semaphore

On Sat, 23 Dec 2000, Sourav Sen wrote:

>
> In many parts of the kernel, I have seen both semaphore is taken
> (eg. down(&current->mm->mmap_sem)) as well as kernel lock (lock_kernel())
> is also taken, why both are required? Whats the purpose of each?
>

because the semaphore is really needed (by design of the subsystem) but
the big kernel lock (BKL) is taken "just in case", i.e. just in case the
design is broken. Occasionally, the lock is removed to "see what
happens" -- if nobody complains then the design is probably correct
i.e. things are declared to "just work" and the attention is shifted to
some other subsystem.... :)

Does it make things clearer?

Regards,
Tigran