[cpp-threads] D2335 (sequential consistency proof) revision

Chris Thomasson cristom at comcast.net
Sat Aug 25 00:31:06 BST 2007


----- Original Message ----- 
From: "Chris Thomasson" <cristom at comcast.net>
To: "Boehm, Hans" <hans.boehm at hp.com>; "C++ threads standardisation" 
<cpp-threads at decadentplace.org.uk>
Cc: "Howard Hinnant" <howard.hinnant at gmail.com>
Sent: Friday, August 24, 2007 4:17 PM
Subject: Re: [cpp-threads] D2335 (sequential consistency proof) revision


> ----- Original Message ----- 
> From: "Boehm, Hans" <hans.boehm at hp.com>
> To: "Chris Thomasson" <cristom at comcast.net>; "C++ threads standardisation"
> <cpp-threads at decadentplace.org.uk>
> Cc: "Howard Hinnant" <howard.hinnant at gmail.com>
> Sent: Friday, August 24, 2007 3:37 PM
> Subject: RE: [cpp-threads] D2335 (sequential consistency proof) revision
>
>
>> From: Chris Thomasson
>>
>> [...]
>>
>> Taking a lock does not necessarily require a #StoreLoad | #StoreStore
>> barrier. There are asymmetric locking algorithms in which
>> certain thread(s)
>> can take the lock without using interlocked rmw or store/load
>> memory barrier
>> instructions.
>>
>
>> You're presumably talking about cases in which a thread knows that it
>> held the lock last?
>
> I am referring to a type of "biased" locking scheme that can designate a
> thread(s) which in turn can take locks without using interlocked rmw or
> membars. Here is a basic example:
[...]

> It kind of resembles epoch
> synchronization in which per-thread/cpu synchronizations are tracked at a
> wider scale than usual:
[...]

Here is a contrived method to implement synchronization epochs with signals:

http://groups.google.com/group/comp.programming.threads/browse_frm/thread/9545d3e17806ccfe


____________
static int volatile g_epoch = 0;


/* mutator thread(s) sig handlers */
void pgc_sig_epoch( int sig ) {
  atomic_dec_release/fence( &g_epoch );
}


/* "single" proxy collector thread */
void* pgc( void *s ) {

    for ( ;; ) {

    /* 1: Wait for polling interval */

    /* 2: Detect sync epochs */

        /* 2a. notify mutators */
        for_each_mutator{
            atomic_inc( &g_epoch );
            pthread_kill( this_thread, ... );
        }

        /* 2b. wait for mutators */
        while ( g_epoch ) {
            /* pause yield, exponential backoff, ect... */
        }

    /* 3: Process sync epoch */
        (...)
    }

    return 0;

}
_____________


The sample pseudo-code above can be used to implement memory barrier free 
reference counting or asymmetric locking... 




More information about the cpp-threads mailing list