volatile Questions

4

This is more of a theoretical question. I'm not sure if all concepts, compiler behaviors, etc. are uptodate and still in use, but I'd like to have confirmation if I'm correctly understanding some c...
Simonette asked 23/4, 2016 at 13:22

0

Generally _Atomic does not imply semantics of volatile, i.e. operations on the atomic object are not observable side effects that the compiler needs to preserve. As a consequence the compiler can o...
Quiroz asked 22/7 at 5:33

0

Generally std::atomic<T> does not imply semantics of volatile, i.e. operations on the atomic object are not observable side effects that the compiler needs to preserve. As a consequence the c...
Stopple asked 22/7 at 2:16

5

Solved

As DateTime cannot be declared as volatile, is this right? private DateTime _time; public DateTime Time { get { Thread.MemoryBarrier(); return _time; } set { _time = value; Thread.MemoryBa...
Tillman asked 28/1, 2011 at 16:13

3

Solved

How is this expected to work? struct S {}; void foo(volatile S&); void foo(S); int main() { volatile S v; foo(v); } Compilers disagree on it: MSVC accepts the code, while Clang and GCC say...

7

Solved

How do I make an array volatile? Because as I've come to understand, it's unsafe to make an array volatile?
Accelerant asked 2/3, 2011 at 21:19

1

Let's consider this trivial code: #include <atomic> std::atomic<int> a; void f(){ for(int k=0;k<100;++k) a.load(std::memory_order_relaxed); } MSVC, Clang and GCC all perform 10...

19

Why is volatile needed in C? What is it used for? What will it do?
Mascot asked 29/10, 2008 at 8:36

1

Can somebody explain the usage of WRITE_ONCE and READ_ONCE? And internally WRITE_ONCE uses a volatile qualifier. Why? How does WRITE_ONCE and READ_ONCE solve cache coherency problem? Difference bet...
Leff asked 29/5, 2018 at 17:2

3

In my main coroutine, I am removing or adding entries from a table depending on user operations. In the background, I'd like to iterate over the entries in the table. I don't mind particularly if I...
Folacin asked 29/5, 2011 at 11:41

12

Solved

Can anyone provide a good explanation of the volatile keyword in C#? Which problems does it solve and which it doesn't? In which cases will it save me the use of locking?
Condolent asked 16/9, 2008 at 13:39

6

Solved

Everything I've read about volatile says it's never safe, but I still feel inclined to try it, and I haven't seen this specific scenario declared unsafe. I have a separate thread that renders a sc...
Stirrup asked 25/2, 2013 at 18:41

2

Solved

MSDN states that: Reads and writes of other types, including long, ulong, double, and decimal, as well as user-defined types, need not be atomic. C# 7.0 draft specification - Variables - 9.6 Atom...
Potbellied asked 15/9, 2012 at 7:8

7

Where is a volatile variable stored in the program memory (in which section)?
Displode asked 3/11, 2009 at 5:39

4

C++20 deprecated some certain operations on volatile types (following P1152). The following code, that was valid prior to C++20: void busyLoop(std::size_t count) { for (volatile size_t counter = 0...
Spoils asked 1/1, 2021 at 10:9

3

The following code sample shows a common way to demonstrate concurrency issues caused by a missing happens-before relationship. private static /*volatile*/ boolean running = true; public static v...

2

Solved

I have a pointer to some volatile memory that I am trying to dereference and copy to a unqualified copy of that structure (and vise-versa). The format of the memory is specified by a third party st...
Extranuclear asked 6/6, 2023 at 0:10

1

volatile int lhs = 1; int rhs = 2; int x = 3; x = lhs = rhs; Does an assigment operator return the (typeof lhs)rhs ? or Does it return new, just read value of lhs ? It is important to me since lh...
Winter asked 11/5, 2023 at 19:23

2

This seems to be similar to POD structs containing constant member, but sort of reversed. #include <iostream> struct A { int a; }; union U { volatile A a; long b; }; int main() { U u1...
Enneahedron asked 5/2, 2015 at 1:53

6

Solved

As a result of my answer to this question, I started reading about the keyword volatile and what the consensus is regarding it. I see there is a lot of information about it, some old which seems wr...
Magnetochemistry asked 9/8, 2011 at 11:17

8

Solved

I got general understanding what volatile means in Java. But reading Java SE Specification 8.3.1.4 I have a problem understanding the text beneath that certain volatile example. class Test { stat...
Hyperopia asked 7/12, 2016 at 20:9

6

Solved

I'm making my own C compiler to try to learn as much details as possible about C. I'm now trying to understand exactly how volatile objects work. What is confusing is that, every read access in the...
Nickolenicks asked 26/1, 2023 at 14:8

9

Solved

Is it correct to say that static means one copy of the value for all objects and volatile means one copy of the value for all threads? Anyway a static variable value is also going to be one value...
Penetrating asked 11/3, 2010 at 9:1

5

Solved

As only reference types and a few primitives (including float, but not double, I'm not sure the reason why, I'm happy to hear why) can be declared as volatile, if I wrap a double in a class then de...
Reisman asked 10/2, 2009 at 10:10

2

Solved

C++ standard allows constexpr volatile variables per defect report 1688, which was resolved in September 2013: The combination is intentionally permitted and could be used in some circumstances to...
Grisaille asked 20/11, 2022 at 20:7

© 2022 - 2024 — McMap. All rights reserved.