Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 719 invoked by uid 500); 13 Jun 2002 23:17:37 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 707 invoked from network); 13 Jun 2002 23:17:36 -0000 Message-ID: <3D0928A3.6040402@textuality.com> Date: Thu, 13 Jun 2002 16:20:03 -0700 From: Tim Bray User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@apr.apache.org Subject: Question re design/usage of lock/mutex routines Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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