atomic Questions
7
Solved
Consider a single memory access (a single read or a single write, not read+write) SSE instruction on an x86 CPU. The instruction is accessing 16 bytes (128 bits) of memory and the accessed memory l...
Deering asked 4/10, 2011 at 9:48
1
Solved
5
Solved
Does a mutex lock access to variables globally, or just those in the same scope as the locked mutex?
Note that I had to change the title of this question, as a lot of answers seem to be confused as...
Elurd asked 13/6, 2016 at 14:15
1
Solved
Pre ARMv6 MPUs/MCUs have SWP instruction (e.g. good ole and still alive ARM7TDMI). In ARMv6 architecture LDREX/STREX pair has been introduced and SWP removed. However with one exception – ARMv6-M (...
5
Solved
Is increment an atomic operation in JavaScript? If one thread is accessing
++i; and at the same time another one starts to access the operation will there be any problems?
Pasteur asked 30/3, 2017 at 11:3
1
Solved
Brief Description:
The code below is an implementation of a lock-free queue from C++ Concurrency in Action 2nd Edition. The queue uses a linked list as the underlying data structure and is implemen...
Filagree asked 19/10, 2022 at 15:4
1
Solved
I am quite new to C++ atomics and memory order and cannot wrap my head around one point. Consider the example taken directly from there: https://preshing.com/20120612/an-introduction-to-lock-free-p...
Rhoea asked 15/10, 2022 at 8:59
2
Consider an atomic read-modify-write operation such as x.exchange(..., std::memory_order_acq_rel). For purposes of ordering with respect to loads and stores to other objects, is this treated as:
a...
Disentomb asked 4/1, 2021 at 18:50
2
Solved
I think I'm missing something obvious here. I have code like this:
int *a = <some_address>;
int *b = <another_address>;
// ...
// desired atomic swap of addresses a and b here
int *tm...
1
Solved
GPU: Quadro RTX 4000
CUDA: 11.7
I have implemented a global lock by atomic operations like:
__global__ void floatAddLockExch(float* addr, volatile int* lock) {
bool goon = true;
while (goon) {
i...
Bog asked 12/9, 2022 at 8:1
3
I know it can happen that g prints 2 and then 0 given the following code.
var a, b uint32
func f() {
a = 1
b = 2
}
func g() {
fmt.Println(b)
fmt.Println(a)
}
func main() {
go f()
g()
}
...
Tavish asked 14/2, 2017 at 16:21
7
Solved
In the Effective Java book, it states:
The language specification guarantees that reading or writing a
variable is atomic unless the variable is of type long or double [JLS,
17.4.7].
What d...
1
Solved
I came across this code for a simple implementation of a barrier (for code that can't use std::experimental::barrier in C++17 or std::barrier in C++20) in C++ Concurrency in Action book.
[Edit]
A b...
Tightrope asked 15/8, 2022 at 4:33
1
Solved
Consider the following test program, compiled and run on an implementation that fully implements C2011 atomics and threads.
#include <stdio.h>
#include <stdatomic.h>
#include <thread...
Fariss asked 2/8, 2022 at 19:6
3
Solved
In C++ we have keyword volatile and atomic class. Difference between them is that volatile does not guarantee thread-safe concurrent reading and writing, but just ensures that compiler will not sto...
Ligan asked 28/10, 2018 at 14:4
3
This is a language-lawyer question.
First of all, does the a.wait() in the following code always get to return?
std::atomic_int a{ 0 };
void f()
{
a.store(1, std::memory_order_relaxed);
a.notify...
Keyhole asked 4/12, 2021 at 18:32
1
Solved
Consider following toy example, especially the result function:
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
class Worker
{
std::thread th;
s...
Gley asked 13/6, 2022 at 17:32
0
Here is a simple example of acquire-release semantics used for data synchronization across threads.
// thread 1 // thread 2
data = 100;
flag.store(true, std::memory_order_release);
while(!flag.loa...
Anabolism asked 16/7, 2022 at 13:5
4
Solved
I want to write some code like this:
var myValue interface{}
func GetMyValue() interface{} {
return atomic.Load(myValue)
}
func StoreMyValue(newValue interface{}) {
atomic.Store(myValue, newVa...
1
Solved
I have read about std::memory_order in C++ and understood partially. But I still had some doubts around it.
Explanation on std::memory_order_acquire says that, no reads or writes in the current th...
Narcis asked 6/7, 2022 at 19:13
1
Solved
So, im programming in C89, and its going well so far except one issue, Im doing multithreaded applications and I need to use atomic.
I dont want to switch to C11 because I want my code to be compat...
Carolyncarolyne asked 2/7, 2022 at 18:8
5
As Integer class is also immutable class and we know that immutable class is thread-safe what is the need of Atomic Integer.
I am confused .
Is it the reason that reads and write of immutable obj...
Mitsue asked 9/8, 2016 at 9:30
0
libc++ shared_ptr implementation release() for the sake of simplicity can be depicted as:
void release()
{
if (ref_count.fetch_sub(1, std::memory_order_acq_rel) == 1)
{
delete this;
}
}
Why do...
Selena asked 17/6, 2022 at 14:42
13
Solved
I sort of understand that AtomicInteger and other Atomic variables allow concurrent accesses. In what cases is this class typically used though?
Autoionization asked 27/1, 2011 at 16:4
3
In my RESTFUL web service which is an online game, I'm storing starting time of every question in an global variable like this: var MyTime time.Time which I should update it after every level of th...
© 2022 - 2024 — McMap. All rights reserved.