> Mb is about to get its first real RT use in PPC RTLinux. The theory with mb()
> is that it provides a "memory barrier" so that 
> /* assume shared_memory=0 and shared_memory2 = 0 */
>                  shared_memory = 1;
>                  mb();
>                  shared_memory2 = 1;
> will mean that another processor  will see shared_memory==1 _before_ it sees
> shared_memory_2==1. Modern processors may queue writes locally so that the local
> CPU sees changes but other CPUs do no. Even worse, writing A,B,C in that order
> does not always mean that A,B,C will be written to memory in that order. Intel
> has very strong memory ordering, but other processors do not, and probably Intel
> will not in the merced and other advanced processors.
> So mb means: flush all writes out to memory and wait until that is done. 

It probably doesn't matter, but it doesn't mean exactly that.  At
least not on the Alpha.  Instead it means: ensure that all the memory
accesses before the MB will occur before any of the ones after the
MB.  That doesn't mean waiting; it can be handled by inserting a
marker in the memory access machinery pipelines.

Do you distinguish a full MB from a "write MB"?  Alpha introduced that 
distinction in the second generation.  The original (full) MB orders
ALL memory references.  Then a "write MB" was added, which enforces
order only for writes.  The reason is that a lot of I/O operations are 
writes, and those are very fast (thanks to write buffers).  A full MB
has to deal with possible pending reads so it generally is implemented 
as a rather costly operation.  On the other hand, MB_Write is simply a 
magic entry in the write buffer that says "don't reorder or merge
writes across one of these markers".  If you are dealing with, say, a
frame buffer, using MB_Write rather than (full) MB can make a major
performance difference.  So in general, you should use MB_Write
whenever that is sufficient, i.e., when there aren't any reads around
that need to have order enforced.

        paul
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to