Presentation on theme: "The meaning of volatile Hans-J. Boehm,. Basic View of Volatile/Atomic If the only races involve synchronization variables (e.g. Java volatiles), then."— Presentation transcript:
Basic View of Volatile/Atomic If the only races involve synchronization variables (e.g. Java volatiles), then multithreaded execution can be viewed as interleaving: –Dekkers example (everything initially zero): Thread 1Thread 2 x = 1;y = 1; r1 = y; r2 = x; –Might be executed as: x = 1; y = 1; r2 = x; r1 = y; or x = 1; y = 1; r1 = y; r2 = x; –Outcome r1 = r2 = 0 is impossible Java volatile, C++0x atomic declare sync. variables. * Provided certain esoteric library calls are avoided.
Details across languages are confusing Java volatiley yy n y n C++0x SC (default) atomic y y y n y y C++0x low level atomic n yy n s as j.u.c.atomicdef yy n def as C + posix volatilen nn y m n Java ordinary variablesn y s n n n C ordinary variablesn nn n n n def=by default as=with alternate syntax s=sometimes m=maybe prohibits r1 = r2 = 0 prohibits r1 = r2 =42 guarantees indivisibility prevents red. load elimination requires fences for X86 x++ is indivisible Note: CLI omitted: in flux?
Your consent to our cookies if you continue to use this website.