lock-free

Does a multiple producer single consumer lock-free queue exist for c++? [closed]

别等时光非礼了梦想. 提交于 2019-12-17 21:50:20
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . The more I read the more confused I become... I would have thought it trivial to find a formally correct mpsc queue implemented in c++. Every time I find another stab at it, further research seems to suggest there are issues such as ABA or other subtle race conditions. Many talk

Is there a production ready lock-free queue or hash implementation in C++ [closed]

走远了吗. 提交于 2019-12-17 04:39:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I ve been googling quite a bit for a lock-free queue in C++. I found some code and some trials - but nothing that i was able to compile. A lock-free hash would also be welcome. SUMMARY: So far i have no positive answer. There is no "production ready" library, and amazingly none of the existent libraries complies

Does volatile prevent introduced reads or writes?

左心房为你撑大大i 提交于 2019-12-14 00:21:50
问题 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 Thing something; volatile int aNumber; void Method() { // Are these lines... var local = something; if (local != null) local.DoThings(); // ...guaranteed not to be transformed into these by compiler, jitter or processor? if (something != null) something.DoThings(); // <-- Second read! // Are these lines..

If this is not a bug in boost::lockfree::detail::freelist, what am I missing here?

十年热恋 提交于 2019-12-13 17:40:56
问题 In this file, the boost::lockfree::detail::freelist class is used to manage storage for a lock-free data structure (e.g., a queue), using a free list. The deallocate_impl method is used to free nodes by linking them back into the free list (a freed node becomes the new head of the free list, displacing the old head). This method is supposed to be thread-safe and lock-free. The original source code of one instance is duplicated here with my comments annotated to point out the suspicious code

Reliable way to ensure a Go channel does not block

风流意气都作罢 提交于 2019-12-13 08:24:28
问题 I'm looking for a reliable to way to make sure an empty channel in Go does not block my execution. I have to iterate through a number of channels in a particular order (kind of priorities), and once I find one with items in it, read one. Currently I do something in a similar way: if len(myChannel) > 0 { // Possible issue here: length could have changed to 0 making this blocking elm := <- myChannel return elm } In theory this could result into too-long of waiting, while a different channel

why is boost lockfree freelist size is limited to a maximum of 65535 objects?

妖精的绣舞 提交于 2019-12-12 11:14:35
问题 Why is the boost lockfree size is fixed to 65535 objects? typedef boost::lockfree::queue<int, boost::lockfree::fixed_size<true>> MyQueue; MyQueue queue(1024*100); The above code throws exception. the reasoning i find in the code is that array-based freelists only support a 16bit address space. what is the reason for this? i am using it on 64bit linux machine. then why limit the addressing to 2**16 items? does the queue use a 'short int' for indexing? does atomic instructions only work for

Lock-free thread-safe queue - need advice

社会主义新天地 提交于 2019-12-12 09:10:50
问题 I need to design a thread-safe logger. My logger must have a Log() method that simply queues a text to be logged. Also a logger must be lock-free - so that other thread can log messages without locking the logger. I need to design a worker thread that must wait for some synchronization event and then log all messages from the queue using standard .NET logging (that is not thread-safe). So what i am interested in is synchronization of worker thread - and Log function. Below is a sketch of the

Does a lock-free queue “multiple producers-single consumer” exist for Delphi?

浪尽此生 提交于 2019-12-12 08:22:48
问题 I've found several implementations for single producer-single consumer, but none for multiple producer-single consumer. Does a lock-free queue for "multiple producers-single consumer" exist for Delphi? 回答1: Lock-free queue from the OmniThreadLibrary supports multiple producers. You can use it separately from the threading library (i.e. you can use OtlContainers unit in any other framework). As the Daniele pointed below, there are two queues in the OmniThreadLibrary. The one in the

Can you avoid locking by guaranteeing that multiple threads won't access the same memory?

孤街醉人 提交于 2019-12-12 07:38:58
问题 Say I have a large array and I want to process the contents with multiple threads. If I delegate each thread to a specific section, guaranteeing no overlap, does that eliminate any need for locking, assuming the threads don't access any other memory outside the array? Something like this (pseudo-code): global array[9000000]; do_something(chunk) { for (i = chunk.start; i < chunk.end; i++) //do something with array } main() { chunk1 = {start: 0, end: 5000000}; chunk2 = {start: 5000000, end:

Do the ARM instructions ldrex/strex have to operate on cache aligned data?

假如想象 提交于 2019-12-12 07:20:28
问题 On Intel, the arguments to CMPXCHG must be cache line aligned (since Intel uses MESI to implement CAS). On ARM, ldrex and strex operate on exclusive reservation granuales. To be clear, does this then mean on ARM the data being operated upon does not have to be cache line aligned? 回答1: It says so right in the ARM Architecture Reference Manual A.3.2.1 "Unaligned data access". LDREX and STREX require word alignment. Which makes sense, because an unaligned data access can span exclusive