[SR-Users] Thread safety of shared variables

Ovidiu Sas osas at voipembedded.com
Wed Nov 19 17:35:02 CET 2014


It shouldn't ... Based on how many workers and cores you have, the
probability of having collisions should be pretty low.  You can
process more then the minimum of workers/cores available on your
server.

Regards,
Ovidiu Sas

On Wed, Nov 19, 2014 at 11:21 AM, Alex Balashov
<abalashov at evaristesys.com> wrote:
> Thanks, it was actually increment I was interested in.
>
> Can one get around it with an intermediate variable?
>
> $var(y) = $shv(x);
> $shv(x) = $var(y) + 1;
>
> I would just use a lock(), but I'm afraid that it will serialise message
> processing too much at high volume, due to the blocking.
>
>
> On 19 November 2014 01:23:14 GMT-05:00, Daniel-Constantin Mierla
> <miconda at gmail.com> wrote:
>>
>> For what kind of operation?
>>
>> Reading or setting the value are safe, but updating it with its own
>> value used in an expression is not.
>>
>> Safe:
>>
>> xlog("value is $sht(x)\n");
>> $sht(x) = 1;
>>
>> Race:
>>
>> $sht(x) = $sht(x) + 1;
>>
>> Cheers,
>> Daniel
>>
>> On 19/11/14 00:27, Alex Balashov wrote:
>>>
>>>  Does setting $shv()s in script require lock()ing, or is it inherently
>>>  thread-safe?
>>>
>>>  Thanks!
>>
>>
>
> --
> Sent from my Nexus 10, with all the figments of autocorrect that might
> imply.
>
> Alex Balashov - Principal
> Evariste Systems LLC
> 235 E Ponce de Leon Ave
> Suite 106
> Decatur, GA 30030
> United States
> Tel: +1-678-954-0670
> Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



-- 
VoIP Embedded, Inc.
http://www.voipembedded.com



More information about the sr-users mailing list