Changeset 2b4a9f26 in mainline for kernel/doc/synchronization


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/doc/synchronization

    rb10e6e31 r2b4a9f26  
    55                                 | spinlock_t |
    66                                 +------------+
     7                                       |
     8                                       +------------------------------+
     9                                                                      |
     10                      INTERRUPTS-DISABLED SPINNING LOCKS              |
     11       irq_spinlock_lock, irq_spinlock_trylock, irq_spinlock_unlock   |
     12                               +----------------+                     |
     13                               | irq_spinlock_t |<--------------------+
     14                               +----------------+
     15
     16
    717
    818                                   WAIT QUEUES
     
    1020                                   +---------+
    1121                                   | waitq_t |
    12                                    +---------+
    13                                   /           \
     22                                   +---------+
     23                                  /           \
    1424               SEMAPHORES        /             \  CONDITION VARIABLES
    1525 semaphore_down_timeout, semaphore_up    condvar_wait_timeout, condvar_signal
     
    1828            +--------------+                         +-----------+
    1929                   |                                       ^
    20                    |                                       |
     30                   |                                       |
    2131                   |                                +------+
    22                    V                               /           
     32                   V                               /
    2333                MUTEXES                           / READERS/WRITERS LOCKS
    2434    mutex_lock_timeout, mutex_unlock   rwlock_reader/writer_lock_timeout, rwlock_unlock
    2535              +---------+                       /        +----------+
    26               | mutex_t |------------------------------->| rwlock_t |
    27               +---------+                     /          +----------+
    28                    |                         /
    29                    +------------------------+
     36              | mutex_t |------------------------------->| rwlock_t |
     37              +---------+                     /          +----------+
     38                   |                         /
     39                   +------------------------+
Note: See TracChangeset for help on using the changeset viewer.