volatile

Should my Akka actors' properties be marked @volatile?

人走茶凉 提交于 2021-02-20 06:01:48
问题 This question looks similar to Should my Scala actors' properties be marked @volatile? but not sure that answer will be the same. As example, in case when the fork-join dispatcher was configured and actor's state wasn't marked by @volatile, is it guarantied that state of the actor will be propagated through the cache hierarchy from one core (or processor) to another if fork/join worker threads run on different cores (or processors)? P.S. Is it right that after JSR133 only one write/read

arm compiler 5 do not fully respect volatile qualifier

瘦欲@ 提交于 2021-02-19 02:59:27
问题 Consider the following code: volatile int status; status = process_package_header(&pack_header, PACK_INFO_CONST); if ((((status) == (SUCCESS_CONST)) ? ((random_delay() && ((SUCCESS_CONST) == (status))) ? 0 : side_channel_sttack_detected()) : 1)) { ... } Which generates this machine code (produced with the toolchain's objdump ): 60: f7ff fffe bl 0 <process_package_header> 64: 9000 str r0, [sp, #0] /* <- storing to memory as status is volatile */ 66: 42a0 cmp r0, r4 /* <- where is the load

Assign volatile to non-volatile sematics and the C standard

浪子不回头ぞ 提交于 2021-02-18 16:14:29
问题 volatile int vfoo = 0; void func() { int bar; do { bar = vfoo; // L.7 }while(bar!=1); return; } This code busy-waits for the variable to turn to 1 . If on first pass vfoo is not set to 1 , will I get stuck inside. This code compiles without warning. What does the standard say about this? vfoo is declared as volatile . Therefore, read to this variable should not be optimized. However, bar is not volatile qualified. Is the compiler allowed to optimize the write to this bar ? .i.e. the compiler

Assign volatile to non-volatile sematics and the C standard

百般思念 提交于 2021-02-18 16:06:43
问题 volatile int vfoo = 0; void func() { int bar; do { bar = vfoo; // L.7 }while(bar!=1); return; } This code busy-waits for the variable to turn to 1 . If on first pass vfoo is not set to 1 , will I get stuck inside. This code compiles without warning. What does the standard say about this? vfoo is declared as volatile . Therefore, read to this variable should not be optimized. However, bar is not volatile qualified. Is the compiler allowed to optimize the write to this bar ? .i.e. the compiler

Assign volatile to non-volatile sematics and the C standard

拥有回忆 提交于 2021-02-18 16:06:32
问题 volatile int vfoo = 0; void func() { int bar; do { bar = vfoo; // L.7 }while(bar!=1); return; } This code busy-waits for the variable to turn to 1 . If on first pass vfoo is not set to 1 , will I get stuck inside. This code compiles without warning. What does the standard say about this? vfoo is declared as volatile . Therefore, read to this variable should not be optimized. However, bar is not volatile qualified. Is the compiler allowed to optimize the write to this bar ? .i.e. the compiler

Order of const and volatile for a variable

北慕城南 提交于 2021-02-16 20:15:09
问题 The following piece of code compiles and runs with gcc version 4.7.2 (Debian 4.7.2-5) : #include <stdio.h> int main() { const volatile x = 3; volatile const y = 4; return 0; } Should I assume that the order of const and volatile is irrelevant? I tried reading up here : encpp ref and it doesn't say anything about the order(or I'm missing it?) 回答1: Yes, the order is irrelevant. In C++, the relevant specification is in 7.1p1, decl-specifier and decl-specifier-seq , which basically explain that

double check locking without volatile (but with VarHandle release/acquire)

橙三吉。 提交于 2021-02-13 12:14:31
问题 The question is rather easy, in a way. Suppose I have this class: static class Singleton { } And I want to provide a singleton factory for it. I can do the (probably) obvious. I am not going to mention the enum possibility or any other, as they are of no interest to me. static final class SingletonFactory { private static volatile Singleton singleton; public static Singleton getSingleton() { if (singleton == null) { // volatile read synchronized (SingletonFactory.class) { if (singleton ==

double check locking without volatile (but with VarHandle release/acquire)

為{幸葍}努か 提交于 2021-02-13 12:13:37
问题 The question is rather easy, in a way. Suppose I have this class: static class Singleton { } And I want to provide a singleton factory for it. I can do the (probably) obvious. I am not going to mention the enum possibility or any other, as they are of no interest to me. static final class SingletonFactory { private static volatile Singleton singleton; public static Singleton getSingleton() { if (singleton == null) { // volatile read synchronized (SingletonFactory.class) { if (singleton ==

double check locking without volatile (but with VarHandle release/acquire)

别等时光非礼了梦想. 提交于 2021-02-13 12:12:39
问题 The question is rather easy, in a way. Suppose I have this class: static class Singleton { } And I want to provide a singleton factory for it. I can do the (probably) obvious. I am not going to mention the enum possibility or any other, as they are of no interest to me. static final class SingletonFactory { private static volatile Singleton singleton; public static Singleton getSingleton() { if (singleton == null) { // volatile read synchronized (SingletonFactory.class) { if (singleton ==

double check locking without volatile (but with VarHandle release/acquire)

烂漫一生 提交于 2021-02-13 12:12:31
问题 The question is rather easy, in a way. Suppose I have this class: static class Singleton { } And I want to provide a singleton factory for it. I can do the (probably) obvious. I am not going to mention the enum possibility or any other, as they are of no interest to me. static final class SingletonFactory { private static volatile Singleton singleton; public static Singleton getSingleton() { if (singleton == null) { // volatile read synchronized (SingletonFactory.class) { if (singleton ==