spinlock

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spinlock相关的知识,希望对你有一定的参考价值。

  Spinlock usually used in code that cannot sleep, thus has higher performance than semaphores.

  Spinlock is implemented as a bit in an integer value.

  Before using, a spinlock must be initialized as follows:

1 spinlock_t my_lock = SPIN_LOCK_UNLOCKED;
2 void spin_lock_init(spinlock_t *lock);

  Beforing entering the critical section, code must obtain the requisite lock with:

1 void spin_lock(spinlock_t *lock);

  Note that all spinlock are uninterruptible, whick means once you call spin_lock, you will spin until the lock become available.

  To release a lock that you have obtained, pass it to:

1 void spin_unlock(spinlock_t *lock);

 

以上是关于spinlock的主要内容,如果未能解决你的问题,请参考以下文章