interlocked Questions
3
Simplified question:
Is there a difference in timing of memory caches coherency (or "flushing") caused by Interlocked operations compared to Memory barriers? Let's consider in C# - any Interlocked...
Reilly asked 13/7, 2014 at 20:48
2
Solved
I've read this topic: C# Thread safe fast(est) counter and have implemented this feature in my parallel code. As far as I can see it all works fine, however it has measurably increased the processi...
Chindwin asked 17/7, 2015 at 17:20
0
Ignore for a moment the absurdity of awaiting an Enumerable.Range call. It's just there to elicit the crash-y behavior. It just as easily could be a method that's doing some network IO to bui...
Snowber asked 20/5, 2015 at 18:55
9
Solved
Asking this question with C# tag, but if it is possible, it should be possible in any language.
Is it possible to implement a doubly linked list using Interlocked operations to provide no-wait lo...
Ferdinande asked 11/5, 2009 at 19:57
1
I need to use Interlocked Operations (CompareExchange, Increment etc.) against memory in MemoryMappedFiles in .NET.
I found this answer to a very similar question. The problem is that Interlocked ...
Juniorjuniority asked 23/9, 2014 at 10:27
1
Solved
We need to share very efficiently block of constantly changing information between two processes. Information fits in 64bits block of memory - so inside one process we'd be able to use Interlocked ...
Yarrow asked 23/5, 2014 at 18:15
1
Solved
I was testing how Interlocked.Increment and lock behave on my computer's architecture because I read the following lines in this article.
As rewritten with Interlocked.Increment, the method shou...
Istle asked 22/12, 2013 at 14:1
1
Solved
I have a migration job and I need to validate the target data when done. To notify the admin of the success/failure of validations, I use a counter to compare the number of rows from table Foo in D...
Backdate asked 16/12, 2013 at 19:45
6
Solved
Just checking... _count is being accessed safely, right?
Both methods are accessed by multiple threads.
private int _count;
public void CheckForWork() {
if (_count >= MAXIMUM) return;
Inter...
Shaftesbury asked 25/10, 2013 at 14:54
1
Solved
I just learned of interlocked class and that it is supposed to be faster than simply locking. Now, this is all nice and good, but I'm curious as to implementation.
As far as I know, the onl...
Alexandros asked 5/9, 2013 at 15:27
4
Solved
I fully appreciate the atomicity that the Threading.Interlocked class provides; I don't understand, though, why the Add function only offers two overloads: one for Integers, another for Longs. Why ...
Modernism asked 9/9, 2009 at 15:41
4
Solved
Microsoft offers the InterlockedCompareExchange function for performing atomic compare-and-swap operations. There is also an _InterlockedCompareExchange intrinsic.
On x86 these are implemented usi...
Porridge asked 12/9, 2009 at 14:24
2
I would like to create a class with two methods:
void SetValue(T value) stores a value, but only allows storing a single value (otherwise it throws an exception).
T GetValue() retrieves the value...
Emelda asked 21/2, 2013 at 14:44
1
Solved
I have include windows.h and want to use InterlockedAdd in vs2010 and compiles error "identifier not found", but the InterlockedIncrement can work well. I try to use:
#include <intrin.h>
#pr...
Sumach asked 30/1, 2013 at 11:56
5
Solved
I've been doing simple multi-threading in VB.NET for a while, and have just gotten into my first large multi-threaded project. I've always done everything using the Synclock statement because I did...
Tontine asked 28/3, 2010 at 21:3
2
Solved
In the following code TimerRecalcStatisticsElapsed should only have one instance of it running. The worker methods that this callback invokes is made to run in sequence, with a maximum of one threa...
Abreu asked 18/5, 2012 at 14:7
2
Solved
I'm trying to understand the logic behind how this class was written, and when I should and shouldn't use it. Any insight would be appreciated
internal struct SpinLock
{
private volatile int lock...
Semen asked 9/5, 2012 at 2:33
6
Solved
Is Interlocked.Increment(ref x) faster or slower than x++ for ints and longs on various platforms?
Hephzibah asked 23/6, 2009 at 17:46
2
Solved
What's the difference between InterlockedCompareExchangeRelease() and InterlockedCompareExchangeAcquire()?
When I try to learn the synchronization functions with WIN32 API, I find there are two fu...
Flora asked 19/3, 2012 at 2:13
3
Solved
I'm attempting to write a thread-safe method which may only be called once (per object instance). An exception should be thrown if it has been called before.
I have come up with two solutions. Are...
Psychopharmacology asked 1/3, 2012 at 10:21
2
Solved
There are a fair share of questions about Interlocked vs. volatile here on SO, I understand and know the concepts of volatile (no re-ordering, always reading from memory, etc.) and I am aware of ho...
Shul asked 6/12, 2011 at 11:58
4
I have read the article Synchronization and Multiprocessor Issues and I have a question about InterlockedCompareExchange and InterlockedExchange. The question is actually about the last example in ...
Draff asked 7/10, 2011 at 9:41
4
Solved
I want to use InterlockedExchange from the WinAPI to use a lock free synchronization of threads.
At the moment I have a class like this.
struct DataExchange
{
volatile LONG m_value;
void SetValu...
Blaise asked 24/5, 2011 at 11:40
2
Solved
I am trying to make following snip of code lockless using interlocked operations, Any idea how to translate this?
if (m_Ref == 0xFFFF)
m_Ref = 1;
else
{
if (++m_Ref == 1)
CallSomething(); //
}...
Moncrief asked 2/5, 2011 at 22:38
3
Solved
Interlocked.Increment seems like among the most standard/simple of operations one would need to perform in multithreaded code.
I assume that the functionality of the method is some sort pattern th...
Aron asked 18/4, 2011 at 8:6
© 2022 - 2024 — McMap. All rights reserved.