[haiku-development] Re: address space rwlock issue?

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 15 Mar 2009 23:53:25 +0100

On 2009-03-15 at 20:08:56 [+0100], Jonas Sundström <jonas@xxxxxxxxxxx> 
wrote:
> Ingo Weinhold <ingo_weinhold@xxxxxx> wrote:
>  ...
> > it is not always known
> > which thread is holding a lock.
> 
> If the kernel doesn´t know, how can locks work
> reliably, let alone be released when processes exit?

Kernelland is a very controlled environment. Only kernel (proper) and 
driver code is executed and that code has certain responsibilities. If a 
function acquires a lock, it is also responsible for releasing it, 
respectively there's a well-defined strategy how the lock is released (e.g. 
some other called function does).

There's only one point where a userland thread can die (regardless whether 
it was caused by {exit,kill}_thread() or whatever), which is in the kernel 
right before the thread would return to userland. At this point no kernel 
locks are held. Kernel threads can only exit explicitly (via exit_thread()) 
and it is the responsibility of that thread/code that no further kernel 
locks are held at that time.

CU, Ingo

Other related posts: