Changeset 2b4a9f26 in mainline for kernel/generic/src/synch/spinlock.c


Ignore:
Timestamp:
2010-05-20T19:30:18Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42bbbe2
Parents:
b10e6e31
Message:

Add interrupts-disabled spinlocks whose purpose is the semantic distinction between spinlocks acquired always with interrupts disabled and normal spinlocks.
The compile-time distinction is implemented by the means of the type system and basic code correctness properties can be checked by the debugging assertions during run-time (with CONFIG_DEBUG)

  • Correct bracketing of top-level interrupts-disabled spinlocks
  • Correctness of the use of nested interrupts-disabled spinlocks (interrupts must be actually disabled)
  • Basic consistency of places where the interrupt level is restored

The API encapsulates the physical manipulation with the interrupt levels and also two common locking patterns

  • Sequential unlocking of spinlock A before locking of spinlock B without restoring original interrupt level (irq_spinlock_pass())
  • Hand-over-hand locking of two locks in the correct locking order, e.g. if A precedes B, then locking of B before unlocking A (irq_spinlock_exchange())

A new HAL function interrupts_disabled() should be implemented in each port to support the run-time checks of correctly disabled interrupts while locking nested interrupts-disabled spinlocks
(only in debug builds, not used in non-debug builds).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/spinlock.c

    rb10e6e31 r2b4a9f26  
    128128void spinlock_unlock_debug(spinlock_t *lock)
    129129{
    130         ASSERT(atomic_get(&lock->val) != 0);
     130        ASSERT_SPINLOCK(atomic_get(&lock->val) != 0, lock);
    131131       
    132132        /*
     
    143143/** Lock spinlock conditionally
    144144 *
    145  * Lock spinlock conditionally.
    146  * If the spinlock is not available at the moment,
    147  * signal failure.
     145 * Lock spinlock conditionally. If the spinlock is not available
     146 * at the moment, signal failure.
    148147 *
    149148 * @param lock Pointer to spinlock_t structure.
Note: See TracChangeset for help on using the changeset viewer.