Am 15.04.2012 16:34, schrieb Blair Zajac:
> On 03/08/2012 01:18 PM, stefan2_at_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.
Received on 2012-04-15 19:11:36 CEST