apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: apr_lock.h lock scope question
Date Mon, 25 Jun 2001 16:37:24 GMT
Aaron Bannert <aaron@ebuilt.com> writes:

> Even in the case where APR_PROCESS_LOCK_IS_GLOBAL is _not_ #defined,
> and the lock was created with type APR_LOCKALL, (if I'm reading this
> correctly) acquire() will do:
> 
> apr_unix_lock_intra(lock)
> apr_unix_lock_inter(lock)
> 
> and release() will do:
> 
> apr_unix_unlock_intra(lock)
> apr_unix_unlock_inter(lock)

What this means is that to block out *all* other processes and
threads, unless we're on a system where APR_PROCESS_LOCK_IS_GLOBAL is
defined, we need to get an interprocess lock (to block out everything
but threads in our own process) as well as a intraprocess lock (to
block out other threads in our own process).

> To me it seems that the intraprocess lock would merely serve as a
> bottleneck (for better or worse) for local-process locks, while the
> interprocess lock would be the only lock protecting the central
> resource.

No...  See my description above of what the interprocess lock does and
what the intraprocess lock does.

> 
> This is compoundedly so when you consider our primary example, where two
> multithreaded processes will compete for the acquire() lock. They can each
> simultaneously acquire the intraprocess lock in their own memory-space,
> but will sill have to compete for the interprocess lock.

If we use a kernel mechanism for interprocess locking which doesn't
block out other threads in the same process then this certainly can
happen.

Generally, APR does use such a kernel mechanism on Unix.

> I also do not see LOCK_ALL used for lock implementation anywhere except
> in the apr/locks/unix/lock.c code. (There is once case in the win32 code,
> but it appears to treat LOCK_ALL and CROSS_PROCESS the same), so the
> who thing seems to hinge on APR_PROCESS_LOCK_IS_GLOBAL. (I could be
> wrong here :)

That simply means that on other platforms and interprocess lock blocks
out other threads in the same process (or that the APR code for those
platforms has a bug :) ).

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...


Mime
View raw message