RTEMS CPU Kit with SuperCore  4.11.3
Files | Data Structures | Macros | Enumerations | Functions
Spinlock Handler

This handler encapsulates functionality which provides the foundation Spinlock services used in all of the APIs supported by RTEMS. More...

Collaboration diagram for Spinlock Handler:

Files

file  corespinlock.c
 Initialize a Spinlock.
 
file  corespinlockrelease.c
 Release a Spinlock.
 

Data Structures

struct  CORE_spinlock_Attributes
 The following defines the control block used to manage the attributes of each spinlock. More...
 
struct  CORE_spinlock_Control
 The following defines the control block used to manage each spinlock. More...
 

Macros

#define CORE_SPINLOCK_STATUS_LAST   CORE_SPINLOCK_UNAVAILABLE
 This is a shorthand for the last status code. More...
 
#define CORE_SPINLOCK_UNLOCKED   0
 This indicates the lock is available. More...
 
#define CORE_SPINLOCK_LOCKED   1
 This indicates the lock is unavailable. More...
 

Enumerations

enum  CORE_spinlock_Status {
  CORE_SPINLOCK_SUCCESSFUL, CORE_SPINLOCK_HOLDER_RELOCKING, CORE_SPINLOCK_NOT_HOLDER, CORE_SPINLOCK_TIMEOUT,
  CORE_SPINLOCK_IS_BUSY, CORE_SPINLOCK_UNAVAILABLE
}
 Core Spinlock handler return statuses. More...
 

Functions

void _CORE_spinlock_Initialize (CORE_spinlock_Control *the_spinlock, CORE_spinlock_Attributes *the_spinlock_attributes)
 Initialize the spinlock. More...
 
CORE_spinlock_Status _CORE_spinlock_Wait (CORE_spinlock_Control *the_spinlock, bool wait, Watchdog_Interval timeout)
 Wait for spinlock. More...
 
CORE_spinlock_Status _CORE_spinlock_Release (CORE_spinlock_Control *the_spinlock)
 Manually release the spinlock. More...
 
RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes (CORE_spinlock_Attributes *the_attributes)
 This method is used to initialize core spinlock attributes. More...
 
RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy (CORE_spinlock_Control *the_spinlock)
 This method is used to determine if the spinlock is available or not. More...
 

Detailed Description

This handler encapsulates functionality which provides the foundation Spinlock services used in all of the APIs supported by RTEMS.

Macro Definition Documentation

◆ CORE_SPINLOCK_LOCKED

#define CORE_SPINLOCK_LOCKED   1

This indicates the lock is unavailable.

Referenced by _CORE_spinlock_Release().

◆ CORE_SPINLOCK_STATUS_LAST

#define CORE_SPINLOCK_STATUS_LAST   CORE_SPINLOCK_UNAVAILABLE

This is a shorthand for the last status code.

Referenced by _POSIX_Spinlock_Translate_core_spinlock_return_code().

◆ CORE_SPINLOCK_UNLOCKED

#define CORE_SPINLOCK_UNLOCKED   0

This indicates the lock is available.

Enumeration Type Documentation

◆ CORE_spinlock_Status

Core Spinlock handler return statuses.

Enumerator
CORE_SPINLOCK_SUCCESSFUL 

This status indicates that the operation completed successfully.

CORE_SPINLOCK_HOLDER_RELOCKING 

This status indicates that the current thread already holds the spinlock.

An attempt to relock it will result in deadlock.

CORE_SPINLOCK_NOT_HOLDER 

This status indicates that the current thread is attempting to unlock a spinlock that is held by another thread.

CORE_SPINLOCK_TIMEOUT 

This status indicates that a thread reached the limit of time it was willing to wait on the spin lock.

CORE_SPINLOCK_IS_BUSY 

This status indicates that a thread is currently waiting for this spin lock.

CORE_SPINLOCK_UNAVAILABLE 

This status indicates that the spinlock is currently locked and thus unavailable.

Function Documentation

◆ _CORE_spinlock_Initialize()

void _CORE_spinlock_Initialize ( CORE_spinlock_Control the_spinlock,
CORE_spinlock_Attributes the_spinlock_attributes 
)

Initialize the spinlock.

This routine initializes the spinlock based on the parameters passed.

Parameters
[in]the_spinlockis the spinlock control block to initialize
[in]the_spinlock_attributesdefine the behavior of this instance

References CORE_spinlock_Control::Attributes, CORE_spinlock_Control::holder, CORE_spinlock_Control::lock, and CORE_spinlock_Control::users.

◆ _CORE_spinlock_Initialize_attributes()

RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes ( CORE_spinlock_Attributes the_attributes)

This method is used to initialize core spinlock attributes.

Parameters
[in]the_attributespointer to the attributes to initialize.

References CORE_spinlock_Attributes::XXX.

◆ _CORE_spinlock_Is_busy()

RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy ( CORE_spinlock_Control the_spinlock)

This method is used to determine if the spinlock is available or not.

Parameters
[in]the_spinlockwill be checked
Returns
This method will return true if the spinlock is busy and false otherwise.

References CORE_spinlock_Control::users.

◆ _CORE_spinlock_Release()

CORE_spinlock_Status _CORE_spinlock_Release ( CORE_spinlock_Control the_spinlock)

Manually release the spinlock.

This routine manually releases the spinlock. All of the threads waiting for the spinlock will be readied.

Parameters
[in]the_spinlockis the spinlock to surrender

References _ISR_Disable, CORE_SPINLOCK_LOCKED, CORE_spinlock_Control::holder, and CORE_spinlock_Control::lock.

◆ _CORE_spinlock_Wait()

CORE_spinlock_Status _CORE_spinlock_Wait ( CORE_spinlock_Control the_spinlock,
bool  wait,
Watchdog_Interval  timeout 
)

Wait for spinlock.

This routine wait for the spinlock to be released. If the spinlock is set to automatic and this is the appropriate thread, then it returns immediately. Otherwise, the calling thread is blocked until the spinlock is released.

Parameters
[in]the_spinlockis the spinlock to wait for
[in]waitis true if willing to wait
[in]timeoutis the maximum number of ticks to spin (0 is forever)
Return values
Astatus is returned which indicates the success or failure of this operation.