Changeset 11 for trunk/kernel/libk/spinlock.c
- Timestamp:
- Apr 26, 2017, 2:29:23 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/spinlock.c
r1 r11 58 58 taken = lock->taken; 59 59 60 // try to take the lock if not already taken 60 61 if( taken == 0 ) 61 62 { 62 // try to take the lock if not already taken63 63 isAtomic = hal_atomic_cas( &lock->taken , 0 , 1 ); 64 64 } … … 69 69 list_add_first( &this->locks_root , &lock->list ); 70 70 71 // enable interrupts if irq_state == NULL 72 if( irq_state ) *irq_state = mode; 73 else hal_restore_irq( mode ); 71 // irq_state must be restored when lock is released 72 *irq_state = mode; 74 73 } 75 74 76 75 ////////////////////////////////////////////// 77 76 void spinlock_unlock_busy( spinlock_t * lock, 78 bool_t restore,79 77 uint32_t irq_state ) 80 78 { … … 86 84 list_unlink( &lock->list ); 87 85 88 if( restore )hal_restore_irq( irq_state );86 hal_restore_irq( irq_state ); 89 87 } 90 88 … … 126 124 } 127 125 128 ///////////////////////////////////////////// /129 uint32_t spinlock_trylock( spinlock_t * lock )126 ///////////////////////////////////////////// 127 error_t spinlock_trylock( spinlock_t * lock ) 130 128 { 131 129 uint32_t mode;
Note: See TracChangeset
for help on using the changeset viewer.