码迷,mamicode.com
首页 > 其他好文 > 详细

spinlock

时间:2017-02-22 18:16:51      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:value   val   style   init   map   ini   semaphore   form   log   

  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

标签:value   val   style   init   map   ini   semaphore   form   log   

原文地址:http://www.cnblogs.com/adera/p/6429910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!