Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
Advice
0 votes
4 replies
147 views

I recently had an interview where I was asked to show how to prevent race conditions in C or C++ between two threads operating on shared data. I used a mutex as follows : pthread_mutex_t mutex; int ...
3 votes
1 answer
255 views

I stumbled into an interesting issue -- when it comes to intrusive lockless stacks (single-linked lists) it seems there is a consensus on how push() should look like. All internet/AI searches (and ...
4 votes
1 answer
112 views

I'm trying to write a bounded lockless single-producer, single-consumer queue, however, the order of elements inserted into the queue is not the same as the order of the elements removed from the ...
1 vote
1 answer
733 views

My situation is this: On a Linux machine I have a shared-memory region inside which lives a ring-buffer of audio samples. This ring-buffer's consumer is a hard-real-time Xenomai audio-callback, so ...
1 vote
0 answers
161 views

I am reading the great paper 《Memory Barriers: a Hardware View for Software Hackers》 written by Paul E. McKenney, which helps me a lot. But I came across a doubt in 《6.2 Example 1》: The author has ...
1 vote
1 answer
116 views

I'm trying to implement a simple yet fast producer/consumer collection with the ability to be copied from another thread and to make it as fast as possible, therefore I am not using any locking ...
1 vote
1 answer
355 views

I have a few questions regarding memory barriers. Say I have the following C code (it will be run both from C++ and C code, so atomics are not possible) that writes an array into another one. Multiple ...
1 vote
1 answer
87 views

I have a question about multithread share variable problem. the two variable is like: { void* a; uint64_t b; } only one thread can modify the two variable, other thread will frequently read ...
0 votes
1 answer
132 views

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 (...
7 votes
2 answers
3k views

There are three different types of "lock-free" algorithms. The definitions given in Concurrency in Action are: Obstruction-Free: If all other threads are paused, then any given thread will ...
1 vote
0 answers
202 views

Am I misunderstanding the builtin CAS operators in gcc? From the docs: bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...) type __sync_val_compare_and_swap (type *ptr, type ...
BadZen's user avatar
  • 4,395
5 votes
1 answer
704 views

Given: std::atomic<uint64_t> b; void f() { std::atomic_thread_fence(std::memory_order::memory_order_acquire); uint64_t a = b.load(std::memory_order::memory_order_acquire); // code ...
5 votes
1 answer
574 views

Given: std::atomic<uint64_t> x; uint64_t f() { x.store(20, std::memory_order::memory_order_relaxed); x.store(10, std::memory_order::memory_order_relaxed); return x.load(std::...
3 votes
1 answer
263 views

I'm using a worker deque as described in "Correct and Efficient Work-Stealing for Weak Memory Models". I want queue items to be 16 bytes in size, and I only care about Intel/AMD Windows x64 ...
iam's user avatar
  • 1,753
-1 votes
1 answer
188 views

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 ...

15 30 50 per page
1
2 3 4 5 6

AltStyle によって変換されたページ (->オリジナル) /