ROC's Proposal for fixing race conditions

Robert,

Thanks for posting your proposal <https://wiki.mozilla.org/User:Roc/AudioBufferProposal>.

It seems as though your proposal could be implemented on any platform with support for copy-on-write page semantics, without requiring neutering any outstanding ArrayBuffers.  E.g., on Posix platforms, the "acquire the contents" step could simply mmap(MAP_PRIVATE) the source memory, and if the original memory contents are modified, the AudioBuffer gets a fresh copy. 

Just as in your proposal, if no one attempts to modify the contents of the AudioBuffer while the contents are "acquired", there is no memory cost, apart from the cost of the mmap() call itself.  If the contents were modified while acquired, they could easily be re-acquired the next time the AudioBuffer is made "live", meaning changes made to "acquired" buffers would propogate to AudioNodes in defined and deterministic ways.  

Implementations in "memory safe" languages without access to low level system calls could use mutexes and read-write locks to achieve the requirement.

So why specify these explicit mechanisms (such as neutering), rather than just a general, implementable requirement: "Modifications to 'acquired contents' must have no affect on live nodes." and allow implementations to fulfill this requirement however they see fit? 

-Jer

Received on Friday, 9 August 2013 05:54:19 UTC