lock-free

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

大城市里の小女人 提交于 2019-12-06 06:20:02
问题 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

Is lock free multithreaded programming making anything easier?

时光毁灭记忆、已成空白 提交于 2019-12-06 05:23:19
问题 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? 回答1: 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

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

╄→гoц情女王★ 提交于 2019-12-06 04:43:15
问题 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

Add the first element to a ConcurrentLinkedQueue atomically

社会主义新天地 提交于 2019-12-06 02:30:25
I want to use a ConcurrentLinkedQueue in an atomic lock-free manner: Several concurrent threads push events into the queue and some other thread will process them. The queue is not bound and I don't want any thread to wait or get locked. The reading part however may notice that the queue got empty. In a lock free implementation the reading thread must not block but will just end its task and proceeds executing other tasks (i.e. as an ExecutorService). Thus the writer pushing the first new event into an empty queue must become aware about it and should restart the reader (i.e. by submitting a

ARM LL/SC exclusive access by register width or cache line width?

无人久伴 提交于 2019-12-05 18:39:32
I'm working on the next release of my lock-free data structure library. I'm using LL/SC on ARM. To use LL/SC as LL/SC (rather than emulating CAS) there has to be a single STR between the LDREX and STREX. Now, I've written the code and this works. What concerns me however is the possibility it may not work. I've read on PowerPC if you access the same cache line as the LL/SC target, you break the LL/SC. So I'm thinking if my STR target is on the same cache line as my LL/SC target, then pow, I'm dead. Now, the LL/SC target and STR targets are always in different malloc()s so the chance of them

ABA in lock free algorithms

守給你的承諾、 提交于 2019-12-05 15:13:11
问题 I understand the ABA problem. But the thing which I am unable to comprehend is: they say that in languages having automatic garbage collection it may not exhibit. So my questions are: How automatic garbage collection prevents ABA problem in happening? Is it possible in java and if yes, how? Is it possible to prevent this from happening? 回答1: When automatic garbage collection is enabled ,no two objects can be allocated with the same reference and co-exist at the same time,that's because as

Lock-free queue

◇◆丶佛笑我妖孽 提交于 2019-12-05 07:01:52
问题 Also I am doing a c implementation and currently have the structure of the queue: typedef struct queueelem { queuedata_t data; struct queueelem *next; } queueelem_t; typedef struct queue { int capacity; int size; queueelem_t *head; queueelem_t *tail; } queue_t; queue_t * queue_init(int capacity) { queue_t *q = (queue_t *) malloc(sizeof(queue_t)); q->head = q->tail = NULL; q->size = 0; q->capacity = capacity; return q; } int CompareAndExchange (void **a, void *comparand,void *new) { int

fastest possible way to pass data from one thread to another

不羁的心 提交于 2019-12-05 03:34:55
I'm using boost spsc_queue to move my stuff from one thread to another. It's one of the critical places in my software so I want to do it as soon as possible. I wrote this test program: #include <boost/lockfree/spsc_queue.hpp> #include <stdint.h> #include <condition_variable> #include <thread> const int N_TESTS = 1000; int results[N_TESTS]; boost::lockfree::spsc_queue<int64_t, boost::lockfree::capacity<1024>> testQueue; using std::chrono::nanoseconds; using std::chrono::duration_cast; int totalQueueNano(0); int totalQueueCount(0); void Consumer() { int i = 0; int64_t scheduledAt; while (i < N

What's the different between LinkedBlockingQueue and ConcurrentLinkedQueue?

一世执手 提交于 2019-12-05 01:46:21
问题 I've read the blog, but i'm not sure whether his conclusion is correct : http://www.javacodegeeks.com/2010/09/java-best-practices-queue-battle-and.html#ixzz1seaiSLwp He said : As you can see from the provided performance results LinkedBlockingQueue achieved the best combined (adding and removing elements) performance results and should be your number one candidate for implementing producer – consumer schenarios. I wonder that, doen't it faster if i don't use lock in my code ? So why the

Lock-free thread-safe queue - need advice

若如初见. 提交于 2019-12-04 15:46:23
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 class that i designed. I think I must use Monitor.Wait/Pulse here or any other means to suspend and