Jump to navigation Jump to search

Source File





When a liblfds data structure is initialized, by the calling of its init function, the work done by that function is and only is valid upon the logical core where the calling thread executed. By valid it is meant to say that the stores (writing initial values to the various variables in the state structure) performed by the init work are not guaranteed to be visible to any other logical core. As such, if threads on other logical cores attempt to use this state structure, rather than seeing sane initial values, they could be reading anything, and then all bets are off.

To make those initial values valid (which is to say, visible) upon other logical cores, threads on those cores need to issue the define LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE, which does that which it says; any init calls, which have completed (i.e. returned) on any other logical cores will now be valid (visible) on this logical core.

The operating system can of course move threads to the logical cores at any time. However, the rule is that if the OS does something to a programme, then the OS must guarantee that programme is not disrupted by what is done. In this case, what this means is that the OS does the necessary work to ensure the thread in question continues to see the world exactly as it did prior to being moved; so as long as the thread in question has called this macro, then the OS will ensure that no matter what moves occurs, the thread continues to have "called the macro", as it were, and all is well.

See Also