Re: [Live-devel] triggerEvent() race condition

2015-03-18 Thread Robert Smith
I would like to use boost::atomic< T> or std::atomic< T> but unfortunately boost and c++11 are unavailable to me. I agree that std::atomic< T> or the like would be the best way to go though. On 03/18/2015 12:16 AM, Jeff Shanab wrote: I have used boost atomic or just a boost mutex with a scoped

Re: [Live-devel] triggerEvent() race condition

2015-03-18 Thread Jeff Shanab
I have used boost atomic or just a boost mutex with a scoped_lock when I needed to protect, It implements cross platform the best avail on a platform. On Tue, Mar 17, 2015 at 9:07 AM, Robert Smith wrote: > Ok, I will implement my own TaskScheduler class, but operations that > read-modify-wri

Re: [Live-devel] triggerEvent() race condition

2015-03-17 Thread Robert Smith
Ok, I will implement my own TaskScheduler class, but operations that read-modify-write memory are not atomic with multiple processors/cores. I guess the large portion of users these days will be using multicore x86 processors. I asked this question on stackoverflow and the responses support th

Re: [Live-devel] triggerEvent() race condition

2015-03-16 Thread Ross Finlayson
> Having thought about it some more, I don't think it's enough to just protect > calls to triggerEvent() because 'fTriggersAwaitingHandling' is still modified > by BasicTaskScheduler::SingleStep(). The intention of the code that implements “BasicTaskScheduler” was that: 1/ The event loop code (w

Re: [Live-devel] triggerEvent() race condition

2015-03-16 Thread Robert Smith
Maybe it's atomic on a single core CPU but it's not going to be safe with multicore CPU's. Having thought about it some more, I don't think it's enough to just protect calls to triggerEvent() because 'fTriggersAwaitingHandling' is still modified by BasicTaskScheduler::SingleStep(). I'm not j

Re: [Live-devel] triggerEvent() race condition

2015-03-16 Thread Ross Finlayson
> But I can't see how the implementation of triggerEvent() can be thread safe, > e.g, the last line: > > fTriggersAwaitingHandling |= eventTriggerId; > > must load, modify and store the value at fTriggersAwaitingHandling It depends on the CPU architecture. In many (if not most?) architectures,

[Live-devel] triggerEvent() race condition

2015-03-16 Thread Robert Smith
I have been diagnosing an issue on a client's system which is streaming six live encoded H264 streams vis multicast RTP and I think the problem lies in the triggerEvent() method. The problem is that some of the streams just stop after a while. I added extensive tracing to our code and identifi