Questions tagged [lockless]

Lockless operations guarantee simultaneous access to data structures without the usage of conventional locks which are generally slow operations like critical sections, mutexes etc. Lockless operations can be achieved with atomic operations for example.

Lockless operations guarantee simultaneous access to data structures without the usage of conventional locks which are generally slow operations like critical sections, mutexes etc. Lockless operations can be achieved with atomic operations() for example.

82 questions
1
vote
2 answers

Advantages and disadvantages of CAS programming

Can anyone give me a summary of the advantages and disadvantages of Compare And Swap programming ? (e.g. multi-core CPU performance) Here's and example in Java: /** * Atomically increments by one the current value. * * @return the updated value …
WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
1
vote
3 answers

Overuse of Interlocked.exchange?

I am trying to understand correct usage of Interlocked.Exchange, so I am implementing a simple sorted LinkedList with add and remove functionality. If this was not a threadsafe list, obviously to find the insertion point, you'd have something like…
user981225
  • 8,762
  • 6
  • 32
  • 41
1
vote
1 answer

Memory Barrer and Visibility - x64

I have read Intel document about memory orderings on x64: http://www.multicoreinfo.com/research/papers/2008/damp08-intel64.pdf .They says that locked instructions cause full barriers which makes processors to see e.g. updates in specified order. But…
rnd
  • 123
  • 7
0
votes
3 answers

Casting a pointer to a volatile void** in C++

I have fairly decent C++ skills, but this one cast has been giving me issues. I have a function that takes in the following parameters: (volatile void **, void * , void*). I have 3 int* variables and I am trying to pass them in as (&var1, var2,…
Seb
  • 3,414
  • 10
  • 73
  • 106
0
votes
1 answer

free(): invalid next size (fast): when use posix_memalign

I use posix_memalign() to alloc place to put my pointers, but when i try to free this place, it comes to this: *** Error in `/home/liqiaochu/lockless_rb/test_lockless_rb': free(): invalid next size (fast): 0x000000000060b000 *** my code is at…
qiaochu li
  • 25
  • 4
0
votes
2 answers

Access violation with lockless queue in multithreaded app

I wrote a simple lockless queue based off of the principles outlined in the msdn article below, and from the DXUT lock free pipe code also…
0
votes
1 answer

Code before/after lock always execute serially?

CodeBlockA; Lock; CodeBlockB; Unlock; CodeBlockC Code block may contain a lot of code, just take it as a unit. Is CodeBlockA CodeBlockB CodeBlockC always execute in serial? How lock achieve this?
Karl
  • 665
  • 4
  • 19
0
votes
2 answers

output 10 with memory_order_seq_cst

When i run this program i get output as 10 which seems to be impossible for me. I'm running this on x86_64 core i3 ubuntu. If the output is 10, then 1 must have come from either c or d. Also in thread t[0], we assign c as 1. Now a is 1 since it…
nvn
  • 157
  • 1
  • 5
0
votes
1 answer

What are the advantages of lock-free programming over spin lock?

I am wondering which are the advantages of lock-free programming over spin lock? I think that when we do lock free programming using CAS mechanism in a thread(called A), if other thread change the value in CAS, A thread still need to loop again. And…
George
  • 35
  • 4
0
votes
1 answer

C++ Lockless Threading Question - Multiple threads iterating over a contiguous array but never accessing same member data?

In my C++ game engine, I have a job system which utilizes worker threads to do various tasks. Threads are affinitized to each available core. Recently, I have been trying to optimize some of my system pipelines by maximizing CPU utilization. Here is…
Paul Renton
  • 2,652
  • 6
  • 25
  • 38
0
votes
1 answer

Lockless circular buffer with single producer singular consumer

I have a consumer thread that must never lock nor allocate memory, and a producer thread that can. I want to implement a two place circular buffer to be able to provide data to the consumer thread from the producer, with the bound that whenever no…
0
votes
0 answers

Lockless linked list Implementation

I'm trying to implement a lockless linked list in C and having it such that you can instantiate multiple instances of the lockless linked list using the create The code is the following: typedef struct node_s node_t; struct node_s { node_t…
coder
  • 119
  • 1
  • 2
  • 10
0
votes
2 answers

Testing locklessness C++

Is there any way to detect whether a function or thread is blocking? I want to build a test case in which I can test whether a function is hard realtime-safe.
Andreas Loanjoe
  • 2,205
  • 10
  • 26
0
votes
1 answer

Add to tail of lock-less list

I'm using the Linux kernel's lock-less list as defined in llist.h. llist_add adds to the list, but it adds the new node right after the head. How can I add to the tail of the list in constant time?
user2233706
  • 6,148
  • 5
  • 44
  • 86
0
votes
1 answer

Why does Linux kernel lock-less list have head and node structs?

I'm trying to understand the lock-less list in the Linux kernel. This is defined in llist.h. Why do they have two structs, to define a list: struct llist_head { struct llist_node *first; }; struct llist_node { struct llist_node…
user2233706
  • 6,148
  • 5
  • 44
  • 86