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.  * This program is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU General Public License
  8.  * as published by the Free Software Foundation; either version
  9.  * 2 of the License, or (at your option) any later version.
  10.  */
  11. #include <linux/interrupt.h>
  12. #include <linux/spinlock.h>
  13. extern spinlock_t kernel_flag;
  14. #define kernel_locked() spin_is_locked(&kernel_flag)
  15. /*
  16.  * Release global kernel lock and global interrupt lock
  17.  */
  18. #define release_kernel_lock(task, cpu) 
  19. do { 
  20. if (task->lock_depth >= 0) 
  21. spin_unlock(&kernel_flag); 
  22. release_irqlock(cpu); 
  23. __sti(); 
  24. } while (0)
  25. /*
  26.  * Re-acquire the kernel lock
  27.  */
  28. #define reacquire_kernel_lock(task) 
  29. do { 
  30. if (task->lock_depth >= 0) 
  31. spin_lock(&kernel_flag); 
  32. } while (0)
  33. /*
  34.  * Getting the big kernel lock.
  35.  *
  36.  * This cannot happen asynchronously,
  37.  * so we only need to worry about other
  38.  * CPU's.
  39.  */
  40. static inline void lock_kernel(void)
  41. {
  42. if (!++current->lock_depth)
  43. spin_lock(&kernel_flag);
  44. }
  45. static inline void unlock_kernel(void)
  46. {
  47. if (--current->lock_depth < 0)
  48. spin_unlock(&kernel_flag);
  49. }