RTEMS
Files | Classes | Macros | Functions

Low-level lock to protect critical sections accessed by threads and interrupt service routines. More...

Files

file  isrlock.h
 ISR Locks.
 

Classes

struct  ISR_lock_Control
 ISR lock control. More...
 
struct  ISR_lock_Context
 Local ISR lock context for acquire and release pairs. More...
 

Macros

#define ISR_LOCK_MEMBER(_designator)   ISR_lock_Control _designator;
 Defines an ISR lock member. More...
 
#define ISR_LOCK_DECLARE(_qualifier, _designator)   _qualifier ISR_lock_Control _designator;
 Declares an ISR lock variable. More...
 
#define ISR_LOCK_DEFINE(_qualifier, _designator, _name)   _qualifier ISR_lock_Control _designator = { SMP_LOCK_INITIALIZER( _name ) };
 Defines an ISR lock variable. More...
 
#define ISR_LOCK_REFERENCE(_designator, _target)   ISR_lock_Control *_designator = _target;
 Defines an ISR lock variable reference. More...
 
#define ISR_LOCK_INITIALIZER(_name)   { SMP_LOCK_INITIALIZER( _name ) }
 Initializer for static initialization of ISR locks. More...
 
#define _ISR_lock_Initialize(_lock, _name)   _SMP_lock_Initialize( &( _lock )->Lock, _name )
 Initializes an ISR lock. More...
 
#define _ISR_lock_Destroy(_lock)   _SMP_lock_Destroy( &( _lock )->Lock )
 Destroys an ISR lock. More...
 
#define _ISR_lock_Set_name(_lock, _name)   _SMP_lock_Set_name( &( _lock )->Lock, _name )
 Sets the name of an ISR lock. More...
 
#define _ISR_lock_ISR_disable_and_acquire(_lock, _context)
 Acquires an ISR lock. More...
 
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
 Releases an ISR lock. More...
 
#define _ISR_lock_Acquire(_lock, _context)
 Acquires an ISR lock inside an ISR disabled section. More...
 
#define _ISR_lock_Release(_lock, _context)
 Releases an ISR lock inside an ISR disabled section. More...
 
#define _ISR_lock_Acquire_inline(_lock, _context)
 Acquires an ISR lock inside an ISR disabled section (inline). More...
 
#define _ISR_lock_Release_inline(_lock, _context)
 Releases an ISR lock inside an ISR disabled section (inline). More...
 
#define _ISR_lock_ISR_disable_profile(_context)
 
#define _ISR_lock_ISR_disable(_context)
 Disables interrupts and saves the previous interrupt state in the ISR lock context. More...
 
#define _ISR_lock_ISR_enable(_context)   _ISR_Local_enable( ( _context )->Lock_context.isr_level )
 Restores the saved interrupt state of the ISR lock context. More...
 

Functions

static __inline__ void _ISR_lock_Context_set_level (ISR_lock_Context *context, ISR_Level level)
 Sets the ISR level in the ISR lock context. More...
 

Detailed Description

Low-level lock to protect critical sections accessed by threads and interrupt service routines.

On single processor configurations the ISR locks degrade to simple ISR disable/enable sequences. No additional storage or objects are required.

This synchronization primitive is supported on SMP configurations. Here SMP locks are used.

Macro Definition Documentation

◆ _ISR_lock_Acquire

#define _ISR_lock_Acquire (   _lock,
  _context 
)
Value:
do { \
_Assert( _ISR_Get_level() != 0 ); \
_SMP_lock_Acquire( \
&( _lock )->Lock, \
&( _context )->Lock_context \
); \
} while ( 0 )
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:128

Acquires an ISR lock inside an ISR disabled section.

The interrupt status will remain unchanged. On SMP configurations this function acquires an SMP lock.

In case the executing context can be interrupted by higher priority interrupts and these interrupts enter the critical section protected by this lock, then the result is unpredictable.

Parameters
[in]_lockThe ISR lock control.
[in]_contextThe local ISR lock context for an acquire and release pair.
See also
_ISR_lock_Release().

Definition at line 284 of file isrlock.h.

◆ _ISR_lock_Acquire_inline

#define _ISR_lock_Acquire_inline (   _lock,
  _context 
)
Value:
do { \
_Assert( _ISR_Get_level() != 0 ); \
_SMP_lock_Acquire_inline( \
&( _lock )->Lock, \
&( _context )->Lock_context \
); \
} while ( 0 )
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:128

Acquires an ISR lock inside an ISR disabled section (inline).

See also
_ISR_lock_Acquire().

Definition at line 326 of file isrlock.h.

◆ _ISR_lock_Destroy

#define _ISR_lock_Destroy (   _lock)    _SMP_lock_Destroy( &( _lock )->Lock )

Destroys an ISR lock.

Concurrent destruction leads to unpredictable results.

Parameters
[in]_lockThe ISR lock control.

Definition at line 196 of file isrlock.h.

◆ _ISR_lock_Initialize

#define _ISR_lock_Initialize (   _lock,
  _name 
)    _SMP_lock_Initialize( &( _lock )->Lock, _name )

Initializes an ISR lock.

Concurrent initialization leads to unpredictable results.

Parameters
[in]_lockThe ISR lock control.
[in]_nameThe name for the ISR lock. This name must be a string persistent throughout the life time of this lock. The name is only used if profiling is enabled.

Definition at line 182 of file isrlock.h.

◆ _ISR_lock_ISR_disable

#define _ISR_lock_ISR_disable (   _context)
Value:
do { \
_ISR_Local_disable( ( _context )->Lock_context.isr_level ); \
_ISR_lock_ISR_disable_profile( _context ) \
} while ( 0 )

Disables interrupts and saves the previous interrupt state in the ISR lock context.

This function can be used in thread and interrupt context.

Parameters
[in]_contextThe local ISR lock context to store the interrupt state.
See also
_ISR_lock_ISR_enable().

Definition at line 392 of file isrlock.h.

◆ _ISR_lock_ISR_disable_and_acquire

#define _ISR_lock_ISR_disable_and_acquire (   _lock,
  _context 
)
Value:
&( _lock )->Lock, \
&( _context )->Lock_context \
)
void _SMP_lock_ISR_disable_and_acquire(SMP_lock_Control *lock, SMP_lock_Context *context)
Disables interrupts and acquires the SMP lock.
Definition: smplock.c:54

Acquires an ISR lock.

Interrupts will be disabled. On SMP configurations this function acquires an SMP lock.

This function can be used in thread and interrupt context.

Parameters
[in]_lockThe ISR lock control.
[in]_contextThe local ISR lock context for an acquire and release pair.
See also
_ISR_lock_Release_and_ISR_enable().

Definition at line 232 of file isrlock.h.

◆ _ISR_lock_ISR_enable

#define _ISR_lock_ISR_enable (   _context)    _ISR_Local_enable( ( _context )->Lock_context.isr_level )

Restores the saved interrupt state of the ISR lock context.

This function can be used in thread and interrupt context.

Parameters
[in]_contextThe local ISR lock context containing the saved interrupt state.
See also
_ISR_lock_ISR_disable().

Definition at line 416 of file isrlock.h.

◆ _ISR_lock_Release

#define _ISR_lock_Release (   _lock,
  _context 
)
Value:
&( _lock )->Lock, \
&( _context )->Lock_context \
)
#define _SMP_lock_Release(lock, context)
Releases an SMP lock.
Definition: smplock.h:304

Releases an ISR lock inside an ISR disabled section.

The interrupt status will remain unchanged. On SMP configurations this function releases an SMP lock.

Parameters
[in]_lockThe ISR lock control.
[in]_contextThe local ISR lock context for an acquire and release pair.
See also
_ISR_lock_Acquire().

Definition at line 310 of file isrlock.h.

◆ _ISR_lock_Release_and_ISR_enable

#define _ISR_lock_Release_and_ISR_enable (   _lock,
  _context 
)
Value:
&( _lock )->Lock, \
&( _context )->Lock_context \
)
#define _SMP_lock_Release_and_ISR_enable(lock, context)
Releases the SMP lock and enables interrupts.
Definition: smplock.h:363

Releases an ISR lock.

The interrupt status will be restored. On SMP configurations this function releases an SMP lock.

This function can be used in thread and interrupt context.

Parameters
[in]_lockThe ISR lock control.
[in]_contextThe local ISR lock context for an acquire and release pair.
See also
_ISR_lock_ISR_disable_and_acquire().

Definition at line 257 of file isrlock.h.

◆ _ISR_lock_Release_inline

#define _ISR_lock_Release_inline (   _lock,
  _context 
)
Value:
&( _lock )->Lock, \
&( _context )->Lock_context \
)
static void _SMP_lock_Release_inline(SMP_lock_Control *lock, SMP_lock_Context *context)
Releases an SMP lock.
Definition: smplock.h:272

Releases an ISR lock inside an ISR disabled section (inline).

See also
_ISR_lock_Release().

Definition at line 345 of file isrlock.h.

◆ _ISR_lock_Set_name

#define _ISR_lock_Set_name (   _lock,
  _name 
)    _SMP_lock_Set_name( &( _lock )->Lock, _name )

Sets the name of an ISR lock.

Parameters
[out]_lockThe ISR lock control.
_nameThe name for the ISR lock. This name must be a string persistent throughout the life time of this lock. The name is only used if profiling is enabled.

Definition at line 211 of file isrlock.h.

◆ ISR_LOCK_DECLARE

#define ISR_LOCK_DECLARE (   _qualifier,
  _designator 
)    _qualifier ISR_lock_Control _designator;

Declares an ISR lock variable.

Do not add a ';' after this macro.

Parameters
_qualifierThe qualifier for the interrupt lock, e.g. extern.
_designatorThe designator for the interrupt lock.

Definition at line 101 of file isrlock.h.

◆ ISR_LOCK_DEFINE

#define ISR_LOCK_DEFINE (   _qualifier,
  _designator,
  _name 
)    _qualifier ISR_lock_Control _designator = { SMP_LOCK_INITIALIZER( _name ) };

Defines an ISR lock variable.

Do not add a ';' after this macro.

Parameters
_qualifierThe qualifier for the interrupt lock, e.g. static.
_designatorThe designator for the interrupt lock.
_nameThe name for the interrupt lock. It must be a string. The name is only used if profiling is enabled.

Definition at line 118 of file isrlock.h.

◆ ISR_LOCK_INITIALIZER

#define ISR_LOCK_INITIALIZER (   _name)    { SMP_LOCK_INITIALIZER( _name ) }

Initializer for static initialization of ISR locks.

Parameters
_nameThe name for the interrupt lock. It must be a string. The name is only used if profiling is enabled.

Definition at line 146 of file isrlock.h.

◆ ISR_LOCK_MEMBER

#define ISR_LOCK_MEMBER (   _designator)    ISR_lock_Control _designator;

Defines an ISR lock member.

Do not add a ';' after this macro.

Parameters
_designatorThe designator for the interrupt lock.

Definition at line 87 of file isrlock.h.

◆ ISR_LOCK_REFERENCE

#define ISR_LOCK_REFERENCE (   _designator,
  _target 
)    ISR_lock_Control *_designator = _target;

Defines an ISR lock variable reference.

Do not add a ';' after this macro.

Parameters
_designatorThe designator for the interrupt lock reference.
_targetThe target for the interrupt lock reference.

Definition at line 133 of file isrlock.h.

Function Documentation

◆ _ISR_lock_Context_set_level()

static __inline__ void _ISR_lock_Context_set_level ( ISR_lock_Context context,
ISR_Level  level 
)
static

Sets the ISR level in the ISR lock context.

Parameters
[out]contextThe ISR lock context.
levelThe ISR level.

Definition at line 159 of file isrlock.h.