atomicity

Can an atomic release be “overwritten”?

有些话、适合烂在心里 提交于 2020-08-05 07:31:10
问题 Say I have atomic<int> i; Thread A performs an atomic store/exchange with memory_order_release. Next, Thread B performs an atomic store with memory_order_release. Thread C performs an atomic fetch_add(0, memory_order_acquire); Does Thread C acquire dependencies from thread A and B or only thread B ? 回答1: Only B (I'm going to assume that by "next" you mean the modification order of the atomic is A -> B -> C so that by [atomics.order]p11 C 's RMW must read the value B wrote). See the note in

Are writes on the PCIe bus atomic?

99封情书 提交于 2020-07-09 07:36:11
问题 I am a newbie to PCIe, so this might be a dumb question. This seems like fairly basic information to ask about PCIe interfaces, but I am having trouble finding the answer so I am guessing that I am missing some information which makes the answer obvious. I have a system in which I have an ARM processor (host) communicating to a Xilinx SoC via PCIe (device). The endpoint within the SoC is an ARM processor as well. The external ARM processor (host) is going to be writing to the register space

Difference btw atomic exchange (without return val) and store? It's about Peterson algorithm with atomic lib

女生的网名这么多〃 提交于 2020-06-27 15:33:26
问题 std::atomic<int> flag0(0),flag1(0),turn(0); void lock(unsigned index) { if (0 == index) { flag0.store(1, std::memory_order_relaxed); turn.exchange(1, std::memory_order_acq_rel); //turn.store(1) while (flag1.load(std::memory_order_acquire) && 1 == turn.load(std::memory_order_relaxed)) std::this_thread::yield(); } else { flag1.store(1, std::memory_order_relaxed); turn.exchange(0, std::memory_order_acq_rel); //turn.store(0) while (flag0.load(std::memory_order_acquire) && 0 == turn.load(std:

Lock-free atomic update to immutable Map

巧了我就是萌 提交于 2020-06-25 05:18:26
问题 Given a Javaslang / Vavr immutable map, and a function that updates that map: private Map<Foo, Bar> myMap = HashMap.empty(); public void setBar(Foo foo, Bar bar) { myMap = myMap.put(foo, bar); } How can I ensure that two concurrent calls to setBar() for different Foo keys will both have their updates recorded? // thread A setBar(fooA, barA) // thread B setBar(fooB, barB) It seems like there's a risk that the calls will be interleaved such that: thread A gets {} thread B gets {} thread B

What is the use case for the atomic exchange (read-write) operation?

房东的猫 提交于 2020-05-11 06:29:30
问题 C++0x specifies the std::atomic template for thread safe atomic access to variables. This template has, among others, a member function std::atomic::exchange that atomically stores a new value in "this" and retrieves the existing value of "this". Win32 has a similar function: InterlockedExchange Now, what these operations do is simple: atomic read-modify. What I do not understand is what the point of this operation is. The value read that is returned is "meaningless", because once I can

Django Unable to rollback with try-exception block for atomic transactions

别说谁变了你拦得住时间么 提交于 2020-03-23 08:00:20
问题 One of my view in Django executes save operations on 6-7 tables. I want these transactions to be atomic I,e if the 5th or 6th transaction fail I want to rollback all the previous saves. The view contains a try-except block to handle the exceptions raised. It looks something like this: @transaction.atomic def my_view(request): sid = transaction.savepoint() try: Table1.save() Table2.save() Table3.save() Table4.save() Table5.save() Table6.save() Table7.save() # This might fail. In case of

How i can process my payload to insert bulk data in multiple tables with atomicity/consistency in cassandra?

早过忘川 提交于 2020-03-05 05:05:08
问题 I have to design the database for customers having prices for millions of materials they acquire through multiple suppliers for the next 24 months. So the database will store prices on a daily basis for every material supplied by a specific supplier for the next 24 months. Now I have multiple use cases to solve so I created multiple tables to solve each use case in the best possible way. Now the insertion of data into these tables will happen on a regular basis in a big chunk (let's say for

How i can process my payload to insert bulk data in multiple tables with atomicity/consistency in cassandra?

别等时光非礼了梦想. 提交于 2020-03-05 05:03:06
问题 I have to design the database for customers having prices for millions of materials they acquire through multiple suppliers for the next 24 months. So the database will store prices on a daily basis for every material supplied by a specific supplier for the next 24 months. Now I have multiple use cases to solve so I created multiple tables to solve each use case in the best possible way. Now the insertion of data into these tables will happen on a regular basis in a big chunk (let's say for

gcc atomic read and writes

泄露秘密 提交于 2020-02-27 08:15:32
问题 I have a multithreaded application where I one producer thread(main) and multiple consumers. Now from main I want to have some sort of percentage of how far into the work the consumers are. Implementing a counter is easy as the work that is done a loop. However since this loop repeats a couple of thousands of times, maybe even more than a million times. I don`t want to mutex this part. So I went looking into some atomic options of writing to an int. As far as I understand I can use the

gcc atomic read and writes

▼魔方 西西 提交于 2020-02-27 08:15:30
问题 I have a multithreaded application where I one producer thread(main) and multiple consumers. Now from main I want to have some sort of percentage of how far into the work the consumers are. Implementing a counter is easy as the work that is done a loop. However since this loop repeats a couple of thousands of times, maybe even more than a million times. I don`t want to mutex this part. So I went looking into some atomic options of writing to an int. As far as I understand I can use the