volatile Questions

1

Solved

Let x and y be variables that are shared between main code and interrupt code. My idea of volatile is that it is only and always needed for hardware variables and interrupt variables that are also...
Hauteur asked 27/6, 2019 at 12:49

4

Solved

I have a global volatile unsigned char array volatile unsigned char buffer[10] to which data is written in an interupt. I have a function that takes an unsigned char * and stores that value to hard...
Thankless asked 25/6, 2019 at 8:7

2

On my platform (X86, Fedora, gcc 9.1.1) sig_atomic_t is typedef'd to a plain int. In the C++ standard, sig_atomic_t is always used with the volatile qualifier. I understand why volatile is needed...
Inconsonant asked 15/6, 2019 at 18:3

1

Solved

Does volatile sig_atomic_t give any memory order guarantees? E.g. if I need to just load/store an integer is it ok to use? E.g. here: volatile sig_atomic_t x = 0; ... void f() { std::thread t([&...
Intricacy asked 14/6, 2019 at 13:14

3

Solved

volatile is to tell the compiler not to optimize the reference, so that every read/write does not use the value stored in register but does a real memory access. I can understand it is useful for s...
Planospore asked 29/3, 2012 at 23:43

2

Solved

Consider the following code: volatile int status; status = process_package_header(&pack_header, PACK_INFO_CONST); if ((((status) == (SUCCESS_CONST)) ? ((random_delay() && ((SUCCESS_...
Mullen asked 1/4, 2019 at 14:44

1

Solved

The C standard states that the volatile keyword should be used in the definition of a variable when there's a chance that the variable's value could change outside the normal flow of execution of t...
Throttle asked 21/3, 2019 at 10:19

4

Solved

Is there a way to declare array elements volatile in Java? I.e. volatile int[] a = new int[10]; declares the array reference volatile, but the array elements (e.g. a[1]) are still not volatile. ...
Decompress asked 10/2, 2010 at 10:53

2

Solved

Is volatile needed for a variable that is read&write in main loop, but read-only in ISR? EDIT: At the moment of writing in main, the ISR is disabled. So, the variable is effectively used atomi...
Filberte asked 3/3, 2019 at 2:38

4

Solved

I am wondering at the difference between declaring a variable as volatile and always accessing the variable in a synchronized(this) block in Java? According to this article http://www.javamex.com/...
Brio asked 19/8, 2010 at 7:34

4

Solved

I had an example from the book 'java concurrency pratique', who says that volatile and immutable holder object gives thread safety. But I do not understand the example given by the book. The code...
Hermann asked 23/7, 2014 at 12:44

8

Solved

I decide I want to benchmark a particular function, so I naïvely write code like this: #include <ctime> #include <iostream> int SlowCalculation(int input) { ... } int main() { std::...
Electrician asked 23/2, 2013 at 14:21

5

Solved

From the specification 10.5.3 Volatile fields: The type of a volatile field must be one of the following: A reference-type. The type byte, sbyte, short, ushort, int, uint, char, float, bool, ...
Reviviscence asked 25/2, 2011 at 3:41

2

Solved

Does Python have the equivalent of the Java volatile concept? In Java there is a keyword volatile. As far as I know, when we use volatile while declaring a variable, any change to the value of tha...
Giaimo asked 14/12, 2018 at 12:57

2

Solved

According to the answer to this question(Java volatile array?), I did the following test: public class Test { public static volatile long[] arr = new long[20]; public static void main(String[] a...
Godsend asked 13/12, 2018 at 1:30

3

Solved

If I have an object which is shared between threads, it seems to me that every field should be either final or volatile, with the following reasoning: if the field should be changed (point to an...
Boggart asked 12/12, 2018 at 8:12

2

Solved

When working with hardware it is sometimes required to perform a read from a specific register discarding the actual value (to clear some flags, for example). One way would be to explicitly read an...
Padlock asked 6/12, 2018 at 19:44

3

I was looking for a thread-safe counter implementation using Interlocked that supported incrementing by arbitrary values, and found this sample straight from the Interlocked.CompareExchange documen...
Cladding asked 26/9, 2011 at 14:33

3

Solved

I've been trying to figure out how to access a mapped buffer from C++17 without invoking undefined behavior. For this example, I'll use a buffer returned by Vulkan's vkMapMemory. So, according to ...
Scopas asked 16/11, 2018 at 15:22

2

Solved

Frankly, this is a continue of this my question, inspired by this answer: https://stackoverflow.com/a/53262717/1479414 Let's suppose we have a class: public class Foo { private Integer x; publ...
Ardra asked 12/11, 2018 at 13:50

6

Solved

Currently I can't understand when we should use volatile to declare variable. I have do some study and searched some materials about it for a long time and know that when a field is declared volat...
Accompanist asked 28/4, 2011 at 9:56

4

Solved

Using a post construct approach when we want to conditionally initialise some of the bean's fields, do we need to care about volatility of the field, since it is a multithread environment? Say, we...
Varve asked 9/11, 2018 at 14:26

7

Solved

I'm compiling a C++ program to run in a freestanding environment and the CPU I'm running on defines a 32-bit peripheral register to be available (edit: memory-mapped) at PERIPH_ADDRESS (aligned cor...

3

Solved

In C#, volatile keyword ensures that reads and writes have acquire and release semantics, respectively. However, does it say anything about introduced reads or writes? For instance: volatile Thin...

7

Solved

How do atomic / volatile / synchronized work internally? What is the difference between the following code blocks? Code 1 private int counter; public int getNextUniqueIndex() { return counter+...
Rental asked 17/3, 2012 at 11:46

© 2022 - 2024 — McMap. All rights reserved.