atomic Questions

3

Recently when I was reading about lock-free programming, I came across "atomic operations". I started digging deep into it. All links explain how to write atomic operations and their usag...
Atropine asked 16/11, 2018 at 6:8

4

Solved

I wanted to understand what does one mean by lock_free property of atomic variables in c++11. I did googled out and saw the other relevant questions on this forum but still having partial understan...
Mcnary asked 5/9, 2012 at 5:52

4

Solved

With reference to: Is rename() atomic? I'm asking something similar, but not quite the same, because what I want to know is is it safe to rely on the atomicty of rename() when using NFS? Here's a...
Monodic asked 28/12, 2016 at 12:18

3

Solved

C++11 introduced the std::atomic<> template library. The standard specifies the store() and load() operations to atomically set / get a variable shared by more than one thread. My question is...
Teece asked 17/9, 2013 at 13:7

1

Solved

[atomics.types.operations] p23 says: bool compare_exchange_weak(T& expected, T desired, memory_order success, memory_order failure) noexcept; Effects: Retrieves the value in expected. It then ...
Americanist asked 18/9, 2023 at 9:34

0

After a release operation A is performed on an atomic object M, the longest continuous subsequence of the modification order of M that consists of: Writes performed by the same thread that perfor...
Vastha asked 10/9, 2023 at 11:57

0

Consider the following C code: #include <stdatomic.h> struct _opaque; typedef struct _opaque *opaque; struct container { _Atomic opaque x; }; struct container get_container(); void consume_...
Garnetgarnett asked 2/9, 2023 at 22:0

2

Can atomic variables in C++11 be initialized globally? For example: std::atomic_int turnX = 5; int main() { /* ... */ } This fails with: error: deleted function ‘std::atomic<int>::atomic(co...
Latex asked 14/7, 2011 at 22:38

1

Solved

According to the C++17 standard, [support.signal], the atomic object should satisfy the following requirements to be used in a signal handler: [...], or f is a non-static member function invoked ...
Azoic asked 18/8, 2022 at 8:9

1

Solved

I know that the -latomic flag is required for the atomic library to be linked in by GCC. However, for some reason std::atomic<int> doesn't require it to build build without latomic while stru...
Alvera asked 7/8, 2023 at 18:54

2

I was looking at the compiler output of rmw atomics from gcc and noticed something odd - on Aarch64, rmw operations such as fetch_add can be partially reordered with relaxed loads. On Aarch64, the...
Autohypnosis asked 5/2, 2016 at 6:11

3

I am working on my demo project - its simple bank. I have one problem. I need to add some virtual money into my account. But I need to do it "like atomic operation", I need to query some ...
Miscarriage asked 12/1, 2022 at 17:55

28

Solved

What do atomic and nonatomic mean in property declarations? @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *user...
Axolotl asked 26/2, 2009 at 2:31

2

The following is a quote from C++ Standard - Memory Order: If an atomic store in thread A is tagged memory_order_release and an atomic load in thread B from the same variable is tagged memory_orde...
Sewell asked 29/9, 2021 at 19:54

1

Solved

Which spinlock method is better (in terms of efficiency)? #include <atomic> #define METHOD 1 int main( ) { std::atomic_flag lock { }; #if METHOD == 1 while ( lock.test_and_set( std::mem...
Destine asked 14/4, 2023 at 7:15

2

Solved

I am currently working a project where I have a large text file (15+ GB) and I'm trying to run a function on each line of the file. In order to speed the task along, I am creating 4 threads and att...

1

I have linking errors, when trying to do an atomic load of a 16 byte block. I have the following code: #include <atomic> struct MyStruct{ long x; long y; }; struct X{ std::atomic<MySt...
Irreligious asked 3/6, 2016 at 11:38

1

Solved

I just found out about the libcu++ library and am trying to use the cuda::atomic variables. I wrote the following program but it is giving me unexpected results: #include <atomic> #include &l...
Percept asked 5/3, 2023 at 7:58

3

Solved

I am trying to implement a simple counter using SQLite provided with Python. I am using CGI to write simple dynamic web pages. It's the only simple way I can think of to implement a counter. The pr...
Thiosinamine asked 16/8, 2011 at 14:12

3

Solved

Is there a way to set, clear, test and flip a single bit as an atomic operation in c++? For example bitwise variants to "compare_and_swap".
Algar asked 26/6, 2017 at 0:9

4

Solved

How do atomic operations work, under the hood? Are atomic operations so-called "wait-free"? I'm seeking for a description of the "least common divisor" of atomic operations. What do all atomic op...
Abell asked 28/7, 2011 at 18:8

5

Solved

I'd like to perform an atomic GET in Redis, and if the value returned is equal to some expected value, I'd like to do a SET, but I want to chain all of this together as one atomic operation. (I'm t...
Pleasure asked 12/5, 2018 at 17:59

1

Solved

If you compile code such as #include <atomic> int load(std::atomic<int> *p) { return p->load(std::memory_order_acquire) + p->load(std::memory_order_acquire); } you see that MSV...
Baribaric asked 30/12, 2022 at 0:40

4

While reading the source codes of Go, I have a question about the code in src/sync/once.go: func (o *Once) Do(f func()) { // Note: Here is an incorrect implementation of Do: // // if atomic.Comp...
Yvor asked 28/1, 2021 at 10:18

5

Solved

Is assigning a pointer atomic in Go? Do I need to assign a pointer in a lock? Suppose I just want to assign the pointer to nil, and would like other threads to be able to see it. I know in Java we ...
Arp asked 30/1, 2014 at 3:49

© 2022 - 2024 — McMap. All rights reserved.