You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Blair Zajac <bl...@orcaware.com> on 2012/04/15 16:34:28 UTC

Re: svn commit: r1298587 - in /subversion/branches/revprop-cache: build.conf subversion/include/private/svn_named_atomic.h subversion/include/svn_error_codes.h subversion/libsvn_subr/svn_named_atomic.c

On 03/08/2012 01:18 PM, stefan2@apache.org wrote:
> Author: stefan2
> Date: Thu Mar  8 21:18:45 2012
> New Revision: 1298587
>
> URL: http://svn.apache.org/viewvc?rev=1298587&view=rev
> Log:
> Define and implement svn_named_atomic__t and associated API.
>
> * subversion/include/private/svn_named_atomic.h
>    new file, containing the new svn_named_atomic API
> * subversion/libsvn_subr/svn_named_atomic.c
>    new file, implements the new API
> * subversion/include/svn_error_codes.h
>    (SVN_ERR_BAD_ATOMIC): new error code used throughout the new API
> * build.conf
>    (libsvn_subr): add new header to exports
>

> +static apr_int64_t
> +synched_add(volatile apr_int64_t *mem, apr_int64_t delta)
> +{
> +  return *mem += delta;
> +}

Is this thread safe?  Could the thread after reading *mem be context 
switched out, another thread calls synced_add(), then the first thread 
does its add and writes the *mem?

Blair



Re: svn commit: r1298587 - in /subversion/branches/revprop-cache: build.conf subversion/include/private/svn_named_atomic.h subversion/include/svn_error_codes.h subversion/libsvn_subr/svn_named_atomic.c

Posted by Stefan Fuhrmann <st...@alice-dsl.de>.
Am 15.04.2012 16:34, schrieb Blair Zajac:
> On 03/08/2012 01:18 PM, stefan2@apache.org wrote:
>> Author: stefan2
>> Date: Thu Mar  8 21:18:45 2012
>> New Revision: 1298587
>>
>> URL: http://svn.apache.org/viewvc?rev=1298587&view=rev
>> Log:
>> Define and implement svn_named_atomic__t and associated API.
>>
>> * subversion/include/private/svn_named_atomic.h
>>    new file, containing the new svn_named_atomic API
>> * subversion/libsvn_subr/svn_named_atomic.c
>>    new file, implements the new API
>> * subversion/include/svn_error_codes.h
>>    (SVN_ERR_BAD_ATOMIC): new error code used throughout the new API
>> * build.conf
>>    (libsvn_subr): add new header to exports
>>
>
>> +static apr_int64_t
>> +synched_add(volatile apr_int64_t *mem, apr_int64_t delta)
>> +{
>> +  return *mem += delta;
>> +}
>
> Is this thread safe?  Could the thread after reading *mem be context 
> switched out, another thread calls synced_add(), then the first thread 
> does its add and writes the *mem?

No those functions are only thread-safe in
combination with the SYNCHRONIZE macro
(see comment in source code).

-- Stefan^2.