[vlc-devel] [PATCH] Support for Http Dynamic Streaming

Felix Abecassis felix.abecassis at gmail.com
Thu May 29 21:11:33 CEST 2014


2014-05-29 20:07 GMT+02:00 Jonathan Thambidurai <jonathan at fastly.com>:

> Hi Remi,
>
> Volatile (threading is irrelevant here) will stop a given (eg
> "chunk->next") from being stored in a register for future accesses.
>
> Thus, let us look at the following simple case (though this is not
> precisely the code),
>
> while(chunk->next);
>
> A compiler can reasonably look at the above, decide that chunk->next
> cannot change, stash it in a register and thus infinitely loop if it is not
> null.  Lets call this execution flow thread 1.
>
> Let us assume that a second thread t2 changes chunk->next.  Since t1 is
> storing what it believes to be chunk->next in a register (and not updating
> it from the actual memory location), t1 will get stuck in whatever state it
> was in in the first place.
>
> I only added the volatile after I ran into exactly the aforementioned
> phenomenon.
>
> Please tell me what you disagree with above.
>
> --Jonathan
>
> But accessing volatile storage does not create a memory barrier so it
might be reordered with non-volatile accesses. Also, it's not necessarily
atomic. So this is generally a bad idea.

You should use atomic variables or a synchronization primitive.

-- 
Félix Abecassis
http://felix.abecassis.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140529/04fcad29/attachment.html>


More information about the vlc-devel mailing list