pcp
[Top] [All Lists]

pcp updates - thread-safe libpcp is done!

To: pcp@xxxxxxxxxxx
Subject: pcp updates - thread-safe libpcp is done!
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Sat, 23 Jul 2011 12:44:17 +1000
With this batch of changes to my pcp4 branch, I'm done with making
libpcp thread-safe.

Now I need some help from others ...

1. I'd really like someone else to audit the changes I've made ... it is
inconceivable that I've got this 100% right ... 8^)>

2. I'd appreciate any assistance in expanding the QA coverage for this
stuff ... new apps, new scripts, new test scenarios, banging the
existing QA on different platforms, ... anything at all and everything
would be helpful.

3. Max, there was an issue raised at the meeting held at the Aconex
offices about context vs channel locking, but my notes don't capture
enough detail to reconstruct your concerns.  The locking currently works
like this
- a global lock to protect the global data structures ... specifically
for contexts this guards an array of pointers to __pmContexts (used to
be an array of __pmContexts) to isolate context creation, duplication
and destruction operations
- a context lock in the __pmContext structure that is set on return from
__pmHandleToPtr() and the caller is responsible for unlocking it when
done with the context handle [note: to avoid deadlock, the caller must
_not_ hold the global lock when __pmHandleToPtr() is called, because the
global lock will be acquired and released by lower-level routines while
the context lock is held]
- a "pmcd" lock that is acquired and held for the duration of a single
PMAPI client <---> PMCD interaction to preserve the synchronous nature
of this IPC
- all of this passes the extended QA using the recently added
multithread*.c group of applications, as well as all the vanilla QA


Changes committed to git://oss.sgi.com/kenj/pcp.git pcp4
(note this is the pcp4 branch)

 man/man3/pmcontrollog.3     |    7 +
 man/man3/pmtraversepmns.3   |   24 ++++
 src/include/pmapi.h         |    1 
 src/libpcp/src/connect.c    |    6 +
 src/libpcp/src/fetch.c      |   63 ++++++-----
 src/libpcp/src/help.c       |   65 ++++-------
 src/libpcp/src/instance.c   |  207 +++++++++++++++----------------------
 src/libpcp/src/logconnect.c |    6 +
 src/libpcp/src/logcontrol.c |    7 +
 src/libpcp/src/p_lrequest.c |   11 ++
 src/libpcp/src/p_lstatus.c  |   11 ++
 src/libpcp/src/pmns.c       |  242 +++++++++++++++++++++-----------------------
 src/libpcp/src/store.c      |   51 +++------
 13 files changed, 352 insertions(+), 349 deletions(-)

commit 9d65d9bf8a72d2d8458d5e59cb4c5496f5d6ebb1
Author: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date:   Sat Jul 23 12:19:48 2011 +1000

    thread-safe libpcp - ipc channel locking, pmTraversePMNS_r()
    
    Three sets of related changes here:
    
    1. add ipc channel locking around the synchronous client<->pmcd 
communication
       supporting pmFetch(), all the (help) text lookup services, all PMNS
       services and all instance domain services
    
    2. add pmTraversePMNS_r() with additional "closure" parameter on the call
       and for the callback method to allow thread-private data to be passed
       from the caller through pmTraversePMNS_r() into the callback method
       [thanks to Greg Banks for suggesting this and explaining to me why
       it is useful ... and multithread9.c in the QA suite now uses this!]
    
    3. additional Thread-safe notes in places where locking is _not_ needed
       for various reasons, or where the locking nuances are not obvious



<Prev in Thread] Current Thread [Next in Thread>