[cpp-threads] modes, pass 2

Alexander Terekhov alexander.terekhov at gmail.com
Wed Aug 31 14:24:02 BST 2005


On 5/11/05, Alexander Terekhov <alexander.terekhov at gmail.com> wrote:
> On 5/11/05, Doug Lea <dl at cs.oswego.edu> wrote:
> [...]
> > 1. There are only a few modes on atomics that are worth exposing
> >    1. load, suppressing any speculative forward loads
> >    2. store, suppressing reorderings wrt preceeding stores
> >    3. store, ensuring that read-after-write works
> 
> Well, apart from dd/cc stuff, full modes atomic_load() and
> atomic_store() in pseudocode for Power is this:
> 
> template<class T, class M> T atomic_load( M msync, T * addr )
> /* "#pragma" */compiler_reordering_constraint_across_this_function( M )
> {
>    if( msync & msync_ssb )
>    {
>        _sync();
>    }
>    else if( msync & msync_slb )
>    {
>        _lwsync();
>    }
> 
>    T 

       r;
    
     if ( msync & msync_serialized ) {

       do {

         r = _load_reserved( addr );

       } while (!store_conditional( addr, r );

     } 
     else {

>      r = _load( addr );
> 
>    if( msync & msync_acq )
>    {
>        _inject_conditional_branch();
>    }

     }
> 
>    if( msync & msync_hlb )
>    {
>        _isync();
>    }
> 
>    return r;
> }

http://groups.google.com/groups?threadm=431581C8.5C645FBC@web.de

regards,
alexander.




More information about the cpp-threads mailing list