spinlock Questions
7
Solved
On an SMP machine we must use spin_lock_irqsave and not spin_lock_irq from interrupt context.
Why would we want to save the flags (which contain the IF)?
Is there another interrupt routine that ...
Grubb asked 1/4, 2010 at 10:11
9
Solved
I think both are doing the same job,how do you decide which one to use for synchronization?
Remontant asked 3/5, 2011 at 13:1
1
I wanted to replace the pthread_spinlock_t example with my own spinlock implementation. However, my implementation's result is literally far lower than the pthread_spinlock_t performance. While the...
Pilcomayo asked 2/10, 2023 at 17:3
0
I've been reverse engineering the EnterCriticalSection function on Windows 10 and found this interesting spin-loop:
It goes:
lbl_loop:
mov ecx, [rsp+60h]
mov ecx, [rsp+60h]
mov ecx, [rsp+60h]
pau...
2
Solved
TL:DR: if a mutex implementation uses acquire and release operations, could an implementation do compile-time reordering like would normally be allowed and overlap two critical sections that should...
Tumulus asked 19/4, 2020 at 4:51
1
Solved
Which spinlock method is better (in terms of efficiency)?
#include <atomic>
#define METHOD 1
int main( )
{
std::atomic_flag lock { };
#if METHOD == 1
while ( lock.test_and_set( std::mem...
Destine asked 14/4, 2023 at 7:15
3
Solved
I am doing experiments with IPC, especially with Mutex, Semaphore and Spin Lock.
What I learnt is Mutex is used for Asynchronous Locking (with sleeping (as per theories I read on NET)) Mechanism, S...
Tartary asked 7/5, 2014 at 7:8
1
Solved
In std::hint there's a spin_loop function with the following definition in its documentation:
Emits a machine instruction to signal the processor that it is running in a busy-wait spin-loop (“spin...
1
Solved
// spinlockAcquireRelease.cpp
#include <atomic>
#include <thread>
class Spinlock{
std::atomic_flag flag;
public:
Spinlock(): flag(ATOMIC_FLAG_INIT) {}
void lock(){
while(flag.tes...
Bestraddle asked 12/1, 2022 at 4:27
11
Solved
I'm using a spin lock to protect a very small critical section. Contention happens very rarely so a spin lock is more appropriate than a regular mutex.
My current code is as follows, and assumes x...
Lutero asked 5/9, 2009 at 13:45
3
Please explain why Busy Waiting is generally frowned upon whereas Spinning is often seen as okay. As far as I can tell, they both loop infinitely until some condition is met.
Bonanno asked 30/6, 2016 at 13:16
2
Solved
'OSSpinLock' was deprecated in iOS 10.0: Use os_unfair_lock() from <os/lock.h> instead
I went through this Question but the provided solution didn't work. Can someone please explain any alternative approach or proper implementation using os_unfair_lock()?
when I am using 'OS_UNFAIR...
4
Solved
I didn't find it in Mac, but almost all Linux os support it..
Any one knows how to port it to mac?
4
Solved
I am new to Linux and am reading Linux device drivers book by Rubini & Corbet. I am confused at one statement related to spinlocks; the book states
If a nonpreemptive uniprocessor system ev...
Corporal asked 15/8, 2013 at 14:21
4
Solved
I am reading Linux Kernel Development recently, and I have a few questions related to disabling preemption.
In the "Interrupt Control" section of chapter 7, it says:
Moreover, disabling interr...
Ashil asked 25/12, 2013 at 6:32
3
Does anyone know Why the perf always show _raw_spin_unlock_irqrestore or some other spin unlock function? The spin_unlock implementation is usually simpler compared with spin_lock. If there is high...
Voodooism asked 23/8, 2017 at 3:56
3
Solved
I'm new to using gcc inline assembly, and was wondering if, on an x86 multi-core machine, a spinlock (without race conditions) could be implemented as (using AT&T syntax):
spin_lock:
mov 0 ea...
Aruwimi asked 4/8, 2011 at 2:15
1
Solved
As of macOS 10.12, OSSpinLock has been deprecated. The XCode error messages urge me to use os_unfair_lock_unlock() instead.
As a legacy of some open source stuff I'm relying on, I'm using RegexKi...
Maypole asked 28/8, 2019 at 16:1
10
Solved
How often do you find yourself actually using spinlocks in your code? How common is it to come across a situation where using a busy loop actually outperforms the usage of locks?
Personally, when I...
Kendricks asked 21/9, 2009 at 18:59
1
Solved
I read an answer on this site says the spin-lock reduce the overhead with context switches, and after that I read an textbook statement related to this:
Spin-lock makes a busy waiting program no...
Trigger asked 25/12, 2018 at 6:19
3
OpenGL red book version 9 (OpenGL 4.5) example 11.13 is Simple Per-Pixel Mutex. It uses imageAtomicCompSwap in a do {} while() loop to take a per-pixel lock to prevent simultaneous access to a shar...
3
Solved
Consider the following spin_lock() implementation, originally from this answer:
void spin_lock(volatile bool* lock) {
for (;;) {
// inserts an acquire memory barrier and a compiler barrier
if ...
Koeppel asked 20/9, 2015 at 9:10
4
Solved
While learning Java 9 features I came across a new method of Thread class, called onSpinWait. As per javadocs, this method is used for this:
Indicates that the caller is momentarily unable to p...
Prosperity asked 19/6, 2017 at 4:43
4
Solved
The pause instruction is commonly used in the loop of testing spinlock, when some other thread owns the spinlock, to mitigate the tight loop. It's said that it is equivalent to some NOP instruction...
Adamson asked 18/1, 2011 at 15:9
2
Solved
In the Linux kernel, arch_spin_lock() is implemented as follows:
static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned int tmp;
arch_spinlock_t lockval, newval;
asm volatile(
/*...
Mellow asked 28/8, 2015 at 17:7
1 Next >
© 2022 - 2025 — McMap. All rights reserved.