<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Maybe it's atomic on a single core CPU but it's not going to be safe
with multicore CPU's.<br>
<br>
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().<br>
<br>
I'm not just speculating! but this problem can take hours to show
it's self so I need to run the test for a long time to be confident
that it's fixed. I have only protected the triggerEvent() method but
I guess the chance of it failing now will be much lower because the
task scheduler thread is probably waiting in a select() call most of
the time.<br>
<br>
I will have to implement my own task scheduler class to be
completely confident though. I get that it's difficult to add
synchronization in a portable way, but at least the documentation
could be updated to highlight the problem.<br>
<br>
Perhaps you could add an interface for a synchronization object and
users could supply their own platform specific implementations.<br>
<br>
<br>
On 03/16/2015 11:18 AM, Ross Finlayson wrote:<br>
<blockquote
cite="mid:0757852E-2DF1-4B39-9906-2A33BB295EB8@live555.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div>
<blockquote type="cite" class="">
<div class="">But I can't see how the implementation of
triggerEvent() can be thread safe, e.g, the last line:<br
class="">
<br class="">
fTriggersAwaitingHandling |= eventTriggerId;<br class="">
<br class="">
must load, modify and store the value at
fTriggersAwaitingHandling</div>
</blockquote>
<div><br class="">
</div>
It depends on the CPU architecture. In many (if not most?)
architectures, it’ll just be a single instruction.</div>
<div><br class="">
</div>
<div>I’d put a mutex around that instruction, if there were a good
portable way of doing so (i.e., portable across Unix and
Windows, and across both old and new compiler versions).</div>
<div><br class="">
</div>
<div>Feel free to put a mutex around your call to “triggerEvent()”
- to see if that solves your problem. (In fact, you should have
done that first, before speculating on this mailing list :-)</div>
<br class="">
<br class="">
<div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate;
color: rgb(0, 0, 0); font-family: Helvetica; font-style:
normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal; orphans: 2;
text-align: -webkit-auto; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px;
-webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px; "><span class="Apple-style-span" style="border-collapse:
separate; color: rgb(0, 0, 0); font-family: Helvetica;
font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: normal;
orphans: 2; text-align: -webkit-auto; text-indent: 0px;
text-transform: none; white-space: normal; widows: 2;
word-spacing: 0px; -webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px; ">Ross Finlayson<br class="">
Live Networks, Inc.<br class="">
<a moz-do-not-send="true" href="http://www.live555.com/"
class="">http://www.live555.com/</a></span></span>
</div>
<br class="">
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
live-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:live-devel@lists.live555.com">live-devel@lists.live555.com</a>
<a class="moz-txt-link-freetext" href="http://lists.live555.com/mailman/listinfo/live-devel">http://lists.live555.com/mailman/listinfo/live-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>