_ _MB Intrinsic (Memory Barrier)

The _ _MB intrinsic has the following declaration:

void __MB( void );

This intrinsic function guarantees that all subsequent loads and stores of data do not access memory until after all previous loads and stores have been completed, as observed by other processors in a multiprocessor system. You do not need to use this function in single-processor systems, except when performing physical I/O.

Memory barriers are very important when writing device drivers, kernel mode code, and multithreaded applications. Note, however, that if a multithreaded application uses the system semaphore application programming interface (API) functions, it need not be concerned with memory barriers because the API functions already have memory barriers included.