I'm laying out plans for a big apache module and figuring out how to do locking/synchronization for in-memory data structures. Classical multiple-reader/one-writer architecture, easy to implement with one atomic & one counting semaphore.

So I'm poking through APR docs, and I find obvious candidates: Global Locking Routines (apr_global_mutex_child_init etc), Process Locking Routines (apr_proc_mutex_create etc), Thread Mutex Routines (apr_thread_mutex_create etc), and Thread RWLock Routines (apr_thread_rwlock_create etc).

Q0: Is there a better place to ask this kind of question or a TFM that I can R? I spent some time in http://apr.apache.org/docs/apr/groupMumble

Q1: I assume global locks dispatch to Process or Thread locks as appropriate, with equivalent semantics?

Q2: How do the global routines decide which to call?

Q3: There is a stern warning in the global locking routines "There is considerable overhead in using this API if only cross-process or cross-thread mutual exclusion is required." Suppose I want to build an apache module that will run in both threaded and forking deployments; do I shut up and swallow the overhead? Or is this question evidence that I'm Unclear On The Concept?

Q4: I really need more or less exactly the RWLock semantics. Is there any particular reason this is thread-only? With ref to Q3 above, does this suggest I'd better build the semantics based on the global locks?

Cheers, Tim



Reply via email to