smplock.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * <asm/smplock.h>
  3.  *
  4.  * Default SMP lock implementation
  5.  */
  6. #include <linux/sched.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/spinlock.h>
  9. extern spinlock_t kernel_flag;
  10. #define kernel_locked() spin_is_locked(&kernel_flag)
  11. /*
  12.  * Release global kernel lock and global interrupt lock
  13.  */
  14. static __inline__ void release_kernel_lock(struct task_struct *task, int cpu)
  15. {
  16. if (task->lock_depth >= 0)
  17. spin_unlock(&kernel_flag);
  18. release_irqlock(cpu);
  19. __sti();
  20. }
  21. /*
  22.  * Re-acquire the kernel lock
  23.  */
  24. static __inline__ void reacquire_kernel_lock(struct task_struct *task)
  25. {
  26. if (task->lock_depth >= 0)
  27. spin_lock(&kernel_flag);
  28. }
  29. /*
  30.  * Getting the big kernel lock.
  31.  *
  32.  * This cannot happen asynchronously,
  33.  * so we only need to worry about other
  34.  * CPU's.
  35.  */
  36. static __inline__ void lock_kernel(void)
  37. {
  38. if (!++current->lock_depth)
  39. spin_lock(&kernel_flag);
  40. }
  41. static __inline__ void unlock_kernel(void)
  42. {
  43. if (--current->lock_depth < 0)
  44. spin_unlock(&kernel_flag);
  45. }