On Mar 4 2014 10:48 AM, Charles Steinkuehler wrote:
> On 3/4/2014 10:55 AM, Jon Elson wrote:
>> Another way this can be dealt with is to have double buffers
>> shared between the two tasks, the "master" task swaps out a
>> pointer
>> to the most recent buffer when it is ready to be used by the
>> "slave" task.  Not sure that is a great way to do things, but
>> it alleviates the deadlock situation.
>
> You are describing a degenerate ring buffer with two elements.
>
> The writing side creates and writes a "chunk" of data, then updates a
> pointer to it.  The read side checks the pointer, and if it has 
> changed,
> it reads the new data.
>
> This process is non-blocking on both sides, cannot deadlock, needs no
> critical sections, and only requires two guarantees to work properly:
>
> 1) The pointer value can be updated atomically.  Most modern systems
> have a way of insuring that values up to 32 bits can be updated
> atomically, and HAL has been relying on this for ages.  Not a 
> problem.
>
> 2) The "chunk" of data needs to be written to physical memory (or
> whatever is used for communications) before the pointer is atomically
> updated.  This is not as easy as it sounds on modern multi-core
> hardware, but in any system where it matters, you will find some form 
> of
> a memory "fence" instruction, that allows software to insure that all
> pending writes occur prior to any subsequent writes.
>
> There are similar requirements that need to be met on the read side, 
> but
> let's not turn this into Parallel Processing Intercommunication 101,
> I've already been through all this with Michael.
>
> It turns out gcc even has special helpers to make all of this magic 
> easy
> to use in portable code, with no need to hack assembly language with 
> a
> bunch of ifdefs for the various CPU families and cache handling
> semantics like back in the "good old days".

I'm not sure I should even mention it, but moving forward should we 
look into using ZFS (which incorporates the "fence" situation you 
mention)?  I just do not know if anyone has analysed ZFS in real-time 
applications...

Anyway, it looks like people that know what they are doing are on it.

   EBo --


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to