首页 > 代码库 > spinlock
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。