  

,        ,   .   -
    ,   .          -
  ,       , 
 ,    .      ,   
    .     -
 . ,  struct foo   
 foo_lock.       
.      ,   , 
   .    ,   ,  
  ,    ;   
    .

  ,   ,    -
    .   
   .      -
  spin_lock_irq ()  spin_unlock_irq ().

spinlock_t mr_lock = SPIN_LOCK_UNLOCKED;

spin_lock_irq(&mr_lock) ;

/*   ... */

spin unlock irqt&mr lock);

      ,    -
.         spin_lock_irq ().
      ,     -
,   ,   ,  ,  
  ,  .

 -

   CONFIG_DEBUG_SPINLOCK    -
   -. ,     -  -
   -   ,
   .       
-.

    -

 spin_lock_init ()    -,
    (  spinlock_t,   
 ,      ).

 spin_try_lock ()     --
.      , ,  
     ,    -
 .     ,   
.   spin_is_locked ()   , 

186  9