[MPlayer-dev-eng] [PATCH] threaded cache, round 2

Dan Oscarsson Dan.Oscarsson at tieto.com
Sun Jan 29 18:20:11 CET 2012


sön 2012-01-29 klockan 11:54 +0100 skrev Reimar Döffinger:
> 
> I don't think that will work, on some architectures there is no
> guarantee when writes will happen, so the following is possible without
> locks:

> Note that this _should_ not be possible on x86 since it has quite a
> strict coherency model (even though it is still confusing and risky
> to rely on such stuff).

Yes, I missed the cache coherency problem of which people are very
uncertain of on the net. It looks like I have to have all setting and
checking of do_work within the mutex lock to ensure cache coherency.
But even there people on the net are somewhat uncertain about cache
coherency.
Though, it could probably be done more efficient on x86.

This also means that "atomic operations" have to ensure cache coherency.

> However in the case of your code you run into another issue:
> you did not mark do_work as volatile, thus since the assignment is
> outside the locks, the _compiler_ is perfectly free to actually move
> the assignment to after the cache reading.

Yes, fixed.

Attached is a new version.

   Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cache-thread.diff
Type: text/x-patch
Size: 3030 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20120129/3714aa8d/attachment.bin>


More information about the MPlayer-dev-eng mailing list