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

Jonathan Thambidurai jonathan at fastly.com
Thu May 29 20:07:05 CEST 2014

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),


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

Please tell me what you disagree with above.


On Wed, May 28, 2014 at 10:48 PM, Jonathan Thambidurai
<jonathan at fastly.com>wrote:

> Apologies,
> Its was definitely sent to the correct address.  Resending here in its
> entirety:
> This patch should take care of the above concerns; it also fixes some bugs.
> The following is noted:
> -volatile was necessary because the compiler was optimizing out some
> memory accesses that were necessary because two threads were (safely)
> operating on the same data structure.  I've reshuffled some code since that
> time, so it may not still occur, but shouldn't hurt.
> -I put the data definitions in a separate header file because I'm likely
> to add some functionality (bitrate changing, seeking, etc), that may
> require adding more .c files to prevent things from getting out of hand.  A
> separate header is a step in that direction.
> -The ultra-large values for segment runs and fragments runs are what I
> imagine are the reasonable worst cases.  The spec. defines nothing in terms
> of hard limits here.  In fact, its quite vague.
> --Jonathan
> On Wed, May 28, 2014 at 10:43 PM, Rémi Denis-Courmont <remi at remlab.net>wrote:
>> Le 2014-05-29 13:27, Jonathan Thambidurai a écrit :
>>  Did you miss ny above explanation about volatile? Or did you find it
>>> insufficient/unconvincing?
>> I cannot find any explanation in the archive...
>> https://mailman.videolan.org/pipermail/vlc-devel/2014-May/thread.html
>> --
>> Rémi Denis-Courmont
> --
> *Jonathan Thambidurai* | Engineer | 650 440 3421
> fastly.com | @fastly <https://twitter.com/fastly> | LinkedIn<http://www.linkedin.com/company/fastly>


*Jonathan Thambidurai* | Engineer | 650 440 3421
fastly.com | @fastly <https://twitter.com/fastly> |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140529/1b202cb8/attachment.html>

More information about the vlc-devel mailing list