Sunday 15 June 2014

What is the meaning of monotonicity in C++ n2660? -



What is the meaning of monotonicity in C++ n2660? -

in "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm"

that says

[monotonicity] accesses single variable v of type t single thread x appear occur in programme order. example, if v 0, x writes 1, , 2 v, no thread (including not limited x) can read value v , subsequently read lower value v. (notice not prevent arbitrary load , store reordering; constrains ordering between actions on single memory location. assumption reasonable on architectures know about. suspect java , clr memory models require assumption also.)

i can't understand relationship between call_once , monotonicity.

and can't find related document it.

please, help.

it means compiler won't reorder actions done on same memory spot. if write:

int = 0; = 1; = 2;

there no way current thread or read i variable value of 2 read same variable find out value 1 or 0.

in linked paper used requirement given pthread_once implementation, if principle not respected, implementation might not work. reason of added requirement seems to avoid memory barrier gain performance.

c++

No comments:

Post a Comment