lock-free

At which level does one unit test lock-free code?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:50:29
Can LLVM, QEMU, GDB, Bochs, OpenStack or the like be used to unit test lock-free concurrent code on an open-source platform? Has anyone achieved this? If you answer by recommending software, I don't mind, but I mention LLVM, QEMU and the others because these function at various different levels. I should like to learn at which level practical success has been found at interleaving threads under unit-test control. I am aware of SPIN/Promela, incidentally. That is fine software but one cannot compile C++, Rust, etc., onto a SPIN/Promela target as far as I know. Examples of existing, open-source

C++ memory_order_consume, kill_dependency, dependency-ordered-before, synchronizes-with

冷暖自知 提交于 2019-12-04 12:50:12
I am reading C++ Concurrency in Action by Anthony Williams. Currently I at point where he desribes memory_order_consume. After that block there is: Now that I’ve covered the basics of the memory orderings, it’s time to look at the more complex parts It scares me a little bit, because I don't fully understand several things: How dependency-ordered-before differs from synchronizes-with? They both create happens-before relationship. What is exact difference? I am confused about following example: int global_data[]={ … }; std::atomic<int> index; void f() { int i=index.load(std::memory_order

lock free arena allocator implementation - correct?

荒凉一梦 提交于 2019-12-04 12:48:51
for a simple pointer-increment allocator (do they have an official name?) I am looking for a lock-free algorithm. It seems trivial, but I'd like to get soem feedback whether my implementaiton is correct. not threadsafe implementation: byte * head; // current head of remaining buffer byte * end; // end of remaining buffer void * Alloc(size_t size) { if (end-head < size) return 0; // allocation failure void * result = head; head += size; return head; } My attempt at a thread safe implementation: void * Alloc(size_t size) { byte * current; do { current = head; if (end - current < size) return 0;

Is lock free multithreaded programming making anything easier?

≡放荡痞女 提交于 2019-12-04 10:05:13
I only read a little bit about this topic, but it seems that the only benefit is to get around contention problems but it will not have any important effect on the deadlock problem as the code which is lock free is so small and fundamental (fifos, lifos, hash) that there was never a deadlock problem. So it's all about performance - is this right? Lock-free programming is (as far as I can see) always about performance, otherwise using a lock is in most cases much simpler, and therefore preferable. Note however that with lock-free programming you can end up trading deadlock for live-lock, which

Lock free constructs in .net

最后都变了- 提交于 2019-12-04 08:38:10
I am new to .net and would like to know whether .net has the java equivalent of AtomicInteger, ConcurrentLinkedQueue, etc? I did a bit of search and couldnt come up with anything. The lock free algorithms need some sort of a CAS instruction, which is provided through the undocumented Unsafe class in Java, does .net have anything equivalent? In .NET there is the Interlocked class, with static methods Interlocked.Increment() and Interlocked.Decrement(). See http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx . You will also find other atomic och synchronization constructs

Do atomic operations become slower as more CPUs are added?

三世轮回 提交于 2019-12-04 07:59:08
问题 x86 and other architectures provide special atomic instructions (lock, cmpxchg, etc.) that allow you to write 'lock free' data structures. But as more and more cores are added, it seems as though the work these instructions will actually have to do behind the scenes will grow (at least to maintain cache coherency?). If an atomic add takes ~100 cycles today on a dual core system, might it take significantly longer on the 80+ core machines of the future? If you're writing code to last, might it

When are lock free data structures less performant than mutual exclusion (mutexes)?

大兔子大兔子 提交于 2019-12-04 07:44:22
问题 I read somewhere (can't find the page anymore) that lock free data structures are more efficient "for certain workloads" which seems to imply that sometimes they're actually slower or the gain from them can be zero in some situations. Taking the ~100 cycle hit of a lock instruction to do an atomic op sounds plenty faster to me than going to sleep and waiting for the scheduler to wake the process back up, so it's not obvious to me under what circumstances a lock free data structure would be

How to implement lock-free skip list

妖精的绣舞 提交于 2019-12-04 07:35:40
问题 I need to implement a lock-free skip list. I tried to look for papers. Unfortunatly all I found was lock-free single linked lists (in many flavors). However how to implement lock-free skip list? 回答1: Lock-free skip lists are described in the book The Art of Multiprocessor Programming, and the technical report Practical lock-freedom, which is based on a PhD thesis on the subject. The skip list discussion begins on page 53. An example implementation, based on these sources, is included in this

Impossible constraint with cmpxchg16b in extended assembly

一笑奈何 提交于 2019-12-04 06:51:55
问题 I am trying to write inline assembly with my C code to perform compare and swap operation. My code is: typedef struct node { int data; struct node * next; struct node * backlink; int flag; int mark; } node_lf; typedef struct searchfrom { node_lf * current; node_lf * next; } return_sf; typedef struct csArg { node_lf * node; int mark; int flag; } cs_arg; typedef struct return_tryFlag { node_lf * node; int result; } return_tf; static inline node_lf cs(node_lf * address, cs_arg *old_val, cs_arg

Is there a lock-free vector implementation?

拟墨画扇 提交于 2019-12-04 02:34:07
First result in Google for "lock free vector" is a research paper cowritten by Damian Dechev, Peter Pirkelbauer and Bjarne Stroustrup describing a theoretical lock-free vector. Has this, or any other lock-free vector, been implemented? MS provides ppl::concurrent_vector and Intel provides tbb::concurrent_vector. On Windows at least ppl and tbb are part of the C-Runtime. I've just looked up what a vector is, in the wikipedia. I think (only a minute or two of thinking, mind) a fully lock-free version is a bit problematic. Consider; you create the array, access it as per normal, etc. For this you