You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Sander Striker <st...@samba-tng.org> on 2001/05/09 11:45:04 UTC

APR memory systems, requirements

Hello again,

To implement shared memory systems, locking is required.
Since memory systems are hiding everything from the user,
locking for allocation and freeing is also hidden.
This means that when a user does a global lock, and
then calls apr_memory_system_malloc() on a shared
memory system (or any memory system doing locking)
a deadlock will occur.
So, we are going to need smart, refcounting locking.
The smart part is in identifying the callers process/thread.
If the same caller locks, just bump the refcount and 
return.

I'm not a locking expert and if I read correctly Ryan and
Greg are already on this, but I want to point out that
this is imho the only way to cleanly implement this
in a way a user doesn't have to twist his brain when
using shared memory :-)

Oh, before I forget, there are ofcourse two locking
issues:

 - locking required for management (ie, malloc etc),
   which is done by the memory system (the implementor
   is responsible for this and should document it).
   Effectively a user doesn't see this and shouldn't
   have to worry about it.

 - locking required for accessing the memory.
   The user has to explicitly call apr_memory_system_lock()
   (to be defined and implemented) for this. In
   case of a non locking memory system this function
   just does nothing and returns. In the case of a
   locking memory system the function calls the
   memory system specific lock function (which has
   to be provided by the memory system implementor).


Sander