spinlock Questions

11

Solved

I always wondered what they are: every time I hear about them, images of futuristic flywheel-like devices go dancing (rolling?) through my mind... What are they?
Cockshy asked 24/12, 2009 at 8:34

1

Solved

There is one spin lock in my code which is shared between two threads. When one thread is holding the lock and the other thread is trying to get the lock, the second thread will keep spinning on a ...
Subscribe asked 27/3, 2017 at 9:54

5

Solved

I know that spinlocks work with spining, different kernel paths exist and Kernels are preemptive, so why spinlocks don't work in uniprocessor systems? (for example, in Linux)
Galina asked 6/2, 2012 at 20:26

1

Solved

I am a little bit confused about the two concepts. definition of lock-free on wiki: A non-blocking algorithm is lock-free if there is guaranteed system-wide progress definition of non-blocki...
Yarmouth asked 14/12, 2016 at 15:40

2

The example implementation Wikipedia provides for a spinlock with the x86 XCHG command is: ; Intel syntax locked: ; The lock variable. 1 = locked, 0 = unlocked. dd 0 spin_lock: mov eax, 1 ; Se...
Fuel asked 19/4, 2016 at 23:23

1

Solved

I am new to the low level stuff so I am completely oblivious of what kind of problems you might face down there and I am not even sure if I understand the term "atomic" right. Right now I am trying...
Vermis asked 15/5, 2016 at 17:37

2

Solved

What are the benefits of using a specifically designed spinlock (e.g. http://anki3d.org/spinlock) vs. code like this: std::mutex m; while (!m.try_lock()) {} # do work m.unlock();
Mckenzie asked 11/2, 2016 at 5:9

2

The original code in Linux kernel is: static inline void __raw_spin_lock_irq(raw_spinlock_t *lock) { local_irq_disable(); preempt_disable(); spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);...
Sabra asked 7/11, 2012 at 5:21

2

Say for example, I have an exclusive atomic-ops-based spin lock implementation as below: bool TryLock(volatile TInt32 * pFlag) { return !(AtomicOps::Exchange32(pFlag, 1) == 1); } void Lock (vola...
Smoulder asked 18/9, 2015 at 17:42

3

Solved

To implement a spinlock in assembly. Here I post a solution I came up with. Is it correct? Do you know a shorter one? lock: mov ecx, 0 .loop: xchg [eax], ecx cmp ecx, 0 je .loop release: ...
Pressley asked 8/4, 2014 at 16:58

1

Solved

I have a setup where I need to lock, read some data, process, write some data, and then unlock. To this end, I made a locking texture as a layout(r32ui) coherent uniform uimage2D. The critical sect...
Nitwit asked 3/2, 2014 at 21:49

2

We try to deploy APC user-cache in a high load environment as local 2nd-tier cache on each server for our central caching service (redis), for caching database queries with rarely changing results,...
Importunate asked 7/11, 2013 at 22:30

3

I wrote some lock-free code that works fine with local reads, under most conditions. Does local spinning on a memory read necessarily imply I have to ALWAYS insert a memory barrier before the spin...
Aromaticity asked 25/7, 2011 at 0:31

1

To give you full context my discussion begun with an observation that I am running a SMP linux (3.0.1-rt11) on ARM cortex A8 based SoC which is a uniprocessor. I was curious to know if there will b...
Alkylation asked 17/1, 2013 at 13:43

2

Solved

The following is a sample spin-lock implementation in the ARM manual. Please check here: http://infocenter.arm.com/help/topic/com.arm.doc.genc007826/Barrier_Litmus_Tests_and_Cookbook_A08.pdf . Sect...
Simplehearted asked 2/5, 2013 at 1:48

1

I have read a lot of docs and articles and posts all over the internet. Almost everyone and everywhere commits that SpinLock is faster for a short running pieces of code, but I made a test, and it ...
Nappe asked 30/1, 2013 at 18:39

1

I have observed that when the linux futexes are contended, the system spends A LOT of time in the spinlocks. I noticed this to be a problem even when futexes are not used directly, but also when ca...
Swansea asked 8/11, 2012 at 16:37

2

Solved

I'm trying to implement a spinlock in my code but the spinlock that I implemented based on Wikipedia results in extremely slow performance. int lockValue = 0; void lock() { __asm__("loop: \n\t" ...
Girdler asked 12/8, 2012 at 14:57

5

Solved

I'm writing a multithreaded application in c++, where performance is critical. I need to use a lot of locking while copying small structures between threads, for this I have chosen to use spinlocks...
Ba asked 14/8, 2012 at 19:26

1

Solved

I have written a small driver to read some data and give it to the user. My driver can be used by more than one application, i.e. it's a reentrant driver, hence the use of a spin lock. But I discov...
Therontheropod asked 4/9, 2012 at 8:30

1

Solved

I found the following spinlock code in boost::smart_ptr: bool try_lock() { return (__sync_lock_test_and_set(&v_, 1) == 0); } void lock() { for (unsigned k=0; !try_lock(); ++k) { if (k<...
Interlingua asked 20/6, 2012 at 1:33

1

Solved

I am trying to use SpinLock, but even this most basic code in a single threaded Console app throws the following exception when I callSpinLock.Exit() System.Threading.SynchronizationLockException ...
Foran asked 27/6, 2012 at 10:27

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

1

If a process holds some spinlocks or semaphores, and exit accidently(e.g., killed by linux), would linux release these locks correctly? If linux doesn't do this work, why?
Giralda asked 19/3, 2012 at 6:55

3

Possible Duplicate: Why can't you sleep while holding spinlock? As far as I know, spinlocks should be used in short duration, and are only choices in code such as interrupt handle...
Cepheus asked 23/10, 2011 at 18:35

© 2022 - 2025 — McMap. All rights reserved.