Re: Holding a spinlock
Re: Holding a spinlock
- Subject: Re: Holding a spinlock
- From: Adriaan van Os <email@hidden>
- Date: Tue, 06 Sep 2016 23:30:37 +0200
Shantonu Sen wrote:
What are you actually trying to do?
If you want to acquire a lock and then execute code in the critical section which might block, you should use a mutex. On x86, kernel mutexes have an adaptive spin before they block on contention, so in practice critical sections of a few instructions should not cause other contending threads to enter the scheduler.
I am just curious to know all the implementation details. I did some tests (in user code) with
various locking/atomic methods and noticed that OSSpinlocks are extremely fast, a zillion times
faster than pthread mutexes. I am writing a (user code) OSSpinlock equivalent that uses a 1-byte
(or 1-bit) flag rather than a 4-byte spinlock. And want to make it as fast as possible.
Regards,
Adriaan van Os
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden