문제

What happens when I use OSSpinLockLock when the lock is already held in the same thread? (hence it should "let me in").

I know it doesn't have a counter, but it's a problem to implement one, because then I'd need to verify this is the thread, the count is zero, and all this would probably need to be locked as well...

도움이 되었습니까?

해결책

If you attempt to lock a spin lock from the thread that already owns it, you will deadlock. Spin locks are not recursive.

You should either look at pthread recursive mutexes, or change your design to avoid having to lock recursively.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top