volatile Questions
7
Solved
A coworker and I write software for a variety of platforms running on x86, x64, Itanium, PowerPC, and other 10 year old server CPUs.
We just had a discussion about whether mutex functions such as ...
Cadaverous asked 26/7, 2011 at 23:10
4
Solved
I'm wondering if a getter method for a private boolean field forces the other threads to get the latest updated value? Is this an alternative for volatile field?
For example:
Class A {
private bo...
Eslinger asked 8/4, 2017 at 12:12
2
I learnt from relaxed ordering as a signal that a store on an atomic variable should be visible to other thread in a "within a reasonnable amount of time".
That say, I am pretty sure it s...
Bettor asked 6/7, 2019 at 8:42
5
Solved
I'm having a theoretical (non-deterministic, hard to test, never happened in practice) hardware issue reported by hardware vendor where double-word write to certain memory ranges may corrupt any fu...
Theocracy asked 20/5, 2021 at 7:51
4
Solved
After looking at a bunch of other questions and their answers, I get the impression that there is no widespread agreement on what the "volatile" keyword in C means exactly.
Even the standard itsel...
Halcomb asked 4/11, 2019 at 14:18
13
I'm reading about volatile keyword in Java and completely understand the theory part of it.
But, what I'm searching for is, a good case example, which shows what would happen if variable wasn't vo...
Counteraccusation asked 19/7, 2013 at 14:2
4
Solved
Joe Albahari has a great series on multithreading that's a must read and should be known by heart for anyone doing C# multithreading.
In part 4 however he mentions the problems with volatile:
N...
Dah asked 2/12, 2016 at 18:27
3
From the book Effective Java:
While the volatile modifier performs no mutual exclusion, it guarantees that any thread that reads the field will see the most recently written value
SO and many oth...
Phosphorus asked 16/3, 2021 at 10:40
3
Solved
public static Singleton singleton;
public static Singleton get(){
synchronized (Singleton.class) {
if (singleton == null) {
singleton = new Singleton();
}
}
return singleton;
}
Some on...
Bibulous asked 16/3, 2021 at 11:12
1
Solved
Both OpenGL and Vulkan allow to obtain a pointer to a part of GPUs memory by using glMapBuffer and vkMapMemory respectively. They both give a void* to the mapped memory. To interpret its contents a...
3
The following example comes from the MSDN.
public class ThreadSafe
{
// Field totalValue contains a running total that can be updated
// by multiple threads. It must be protected from unsynchroni...
Pushed asked 5/3, 2021 at 7:54
1
Writes to volatile variables are somehow side effects in C++ and generally can't be optimized out under as-if rule, usually. In practice, this usually means that on inspection of the assembly...
Franklyn asked 10/2, 2021 at 7:24
2
Solved
In my case, I want to implement the Acquire/Release model in java8 with volatile.
So I write the code that uses a volatile shared variable I to guarantee the modifying of MAP could be seen by other...
Phenanthrene asked 29/1, 2021 at 9:23
2
Solved
I'm learning the JDK9 memory model.
After watching the speech
Java Memory Model Unlearning Experience
and reading the paper
Using JDK 9 Memory Order Modes.
I'm confused about some concepts.
Does o...
Rizas asked 26/1, 2021 at 6:36
4
Solved
Note
By saying that a memory access can (or cannot) be reordered I meand that it can be
reordered either by the compiler when emitting byte code byte or by the JIT when emitting
machine code or by...
Witkowski asked 22/7, 2015 at 22:50
19
Solved
What does the volatile keyword do? In C++ what problem does it solve?
In my case, I have never knowingly needed it.
2
Solved
Suppose I have a struct like this:
volatile struct { int foo; int bar; } data;
data.foo = 1;
data.bar = 2;
data.foo = 3;
data.bar = 4;
Are the assignments all guaranteed not to be reordered?
For e...
Chesney asked 14/12, 2020 at 20:19
2
Solved
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 m...
Kristelkristen asked 6/12, 2020 at 18:57
3
Solved
I am watching video from java jpoint conference.
I have question about following slide from Alexey Shipilev report:
Excuse me for non-english on slide. Actually author says that it is impossibl...
Tellurate asked 23/10, 2017 at 12:37
4
Solved
Does Java allows output 1, 0? I've tested it very intensively and I cannot get that output. I get only 1, 1 or 0, 0 or 0, 1.
public class Main {
private int x;
private volatile int g;
// Execu...
Melburn asked 16/7, 2017 at 22:29
4
Solved
Is it necessary to use volatile when writing to hardware (say a FIFO) in C or C++. It is easy to confirm from online documentation that volatile is necessary when reading hardware, but what about w...
4
Solved
I've seen some flavors of these question around and I've seen mixed answers, still unsure whether they are up-to-date and fully apply to my use case, so I'll ask here. Do let me know if it's a dupl...
1
Solved
According to cppreference, std::construct_at(T*p, Args&&... args) is equivalent to
return ::new (const_cast<void*>(static_cast<const volatile void*>(p)))
T(std::forward<Args...
Thisbe asked 9/8, 2020 at 10:36
1
Solved
I was wondering about the equivalent of Java's "volatile", and found this answer.
An equivalent to Java volatile in Python
Which (basically) says that everything is effectively volatile i...
Elizabetelizabeth asked 24/7, 2020 at 17:42
9
In my scenario, I have DirtyArray objects that are basically primitive array wrappers that set a boolean "dirty" flag when a write access happens.
public class DirtyArray {
private byte[...
Hyperopia asked 17/6, 2020 at 19:46
© 2022 - 2024 — McMap. All rights reserved.