[cpp-threads] modes, pass 2

Alexander Terekhov alexander.terekhov at gmail.com
Mon May 9 19:17:36 BST 2005


On 5/9/05, Peter Dimov <pdimov at mmltd.net> wrote:
> Alexander Terekhov wrote:
> > I think that the trick can be used for your get_acquire().
> 
> Yep. In "compilable pseudocode":
> 
> template<class T, class M> T atomic_load( M msync, T * addr )
> {
>    if( msync & msync_ssb )
>    {
>        _sync();
>    }
>    else if( msync & msync_slb )
>    {
>        _lwsync();
>    }
> 
>    T r = _load( addr );
> 
>    if( msync & msync_acq )
>    {
>        _inject_conditional_branch();
>    }
> 
>    if( msync & msync_hlb )
>    {
>        _isync();
>    }
> 
>    return r;
> }

Yup. With compile time ifs, "_inject_conditional_branch()" meaning 
r->CR0->branch-never-taken hack, msync_acq == msync_hsb | msync_hlb, 
and Doug's "lightest barrier" stuff implied.

regards,
alexander.




More information about the cpp-threads mailing list