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
0
votes
0 answers

Do I need to use mutex for single consumer + single producer?

I have single producer putting jobs in a queue one by one, and another thread taking jobs away from the queue one by one. I saw somewhere online that it can be done locklessly. What is the right thing to do? Are lockless implementations generally…
ijklr
  • 145
  • 8
0
votes
1 answer

Which one is faster atomic_compare_and_swap or spin trylock?

Below is my use case I have one global variable and multiple thread across all CPU are accessing this. With atomic compare and exchange auto old = global_var; auto new_var = old for (;;) { new++; bool got_it =…
eswaat
  • 733
  • 1
  • 13
  • 31
0
votes
1 answer

Interlocked.Exchange Collection Modified Exception

I am trying to create a form of Buffered Input to see how easy it would be to implement, without the use of Rx or any other library (outside standard .net 4.5). So I came up with the following class: public class BufferedInput { private Timer…
Stuart Blackler
  • 3,732
  • 5
  • 35
  • 60
0
votes
2 answers

Any way to maintain data consistency without using locks?

I'm trying to implement a cache for data fetched from external data source. I'm trying to figure out if I can avoid locks all together and use timestamps to ensure that stale data is never inserted in cache. Is there a mechanism already developed…
0
votes
4 answers

Lockless Deque in Win32 C++

I'm pretty new to lockless data structures, so for an exercise I wrote (What I hope functions as) a bounded lockless deque (No resizing yet, just want to get the base cases working). I'd just like to have some confirmation from people who know what…
Reggie
  • 73
  • 1
  • 5
-1
votes
1 answer

Lockless multithreading of an integer

Given a scenario where there's a function that should only be executed by one thread at any given time, and the rest just return (since a specific state is already being worked on), what's the best way to accomplish this? public void RunOnce() { …
Dennis19901
  • 615
  • 6
  • 9
-1
votes
3 answers

Does this implementation work for a Lock-less Thread Safe Lazy Singleton in Java?

This is what I have so far, am I going in the right direction? Aim is to use this in scenarios where one thread requires access to the singleton more frequently than other threads, hence lock-less code is desirable, I wanted to use atomic variables…
newlogic
  • 807
  • 8
  • 25
1 2 3 4 5
6