Global

group Global_spinlock

spinlock globals

lorem

Macros

group Macros_spinlock_h

Variables

group Variables_spinlock_h

API’s

group Apis_spinlock_h

Getters

group Getters_spinlock_h

Functions

CosmOS_SpinlockStateType spinlock_getSpinlock(BitWidthType spinlockId)

Get spinlock. DEMO.

The implementation contains obtaining of the operating system and core configuration by calling functions os_getOsCfg and CILcore_getCoreCfg. Then the operating system configuration in function os_getOsNumberOfSpinlocks to get number of spinlocks. The input element id argument is then checked againts the number of spinlock, if it is greater than number of spinlocks SPINLOCK_STATE_ENUM__ERROR_INVALID_ID is returned. Spinlock variable is then obtained based on the id argument by the function os_getOsSpinlockVar. The function spinlock_willCauseDeadlock is called to check if the spinlock would cause eventually deadlock, if yes the spinlock state SPINLOCK_STATE_ENUM__ERROR_DEADLOCK is returned. Otherwise the function cosmosApiInternal_spinlock_getSpinlockInternal is called if the core is in the privileged mode or spinlock_getSpinlockInternal is called to get spinlock and result is then returned as spinlock state. The schedulable owner member in spinlock variable is set to the schedulable in execution.

Parameters

spinlockId[in] spinlock identifier

Returns

CosmOS_SpinlockStateType

Setters

group Setters_spinlock_h

Functions

void spinlock_setSpinlockValue(CosmOS_SpinlockVariableType *spinlockVar, BitWidthType spinlockParam)

Set spinlock value. This function cannot be called from the unprivileged context directly.

Parameters
  • spinlockVar[out] pointer

  • spinlockParam[in] value to be set to the spinlock variable

Returns

none

void spinlock_setSpinlockSchedulableOwner(CosmOS_SpinlockVariableType *spinlockVar, CosmOS_SchedulableConfigurationType *schedulableOwnerParam)

Set spinlock schedulableOwner. This function cannot be called from the unprivileged context directly.

Parameters
  • spinlockVar[out] pointer

  • schedulableOwnerParam[in] pointer to the schedulable that owns current spinlock

Returns

none

General

group General_spinlock_h

Functions

CosmOS_SpinlockStateType spinlock_trySpinlockInternal(BitWidthType id, CosmOS_SpinlockVariableType *spinlockVar, BitWidthType spinlockId)

Try to get spinlock internal. This function cannot be called from the unprivileged context directly. DEMO.

The implementation contains obtaining of the core configuration by calling function CILcore_getCoreCfg. Then the function CILspinlock_trySpinlock is called to try to get spinlock and result is then returned as spinlock state. The if condition is implemented to check if the result from CILspinlock_trySpinlock is equal to the SPINLOCK_STATE_ENUM__SUCCESSFULLY_LOCKED and if yes the schedulable owner member in spinlock variable is set to the schedulable in execution.

Parameters
  • id[in] is used during the system call dispatching

  • spinlockVar[in] variable structure pointer

  • spinlockId[in] spinlock identifier

Returns

CosmOS_SpinlockStateType

CosmOS_SpinlockStateType spinlock_releaseSpinlockInternal(BitWidthType id, CosmOS_SpinlockVariableType *spinlockVar, BitWidthType spinlockId)

Release to get spinlock internal. This function cannot be called from the unprivileged context directly. DEMO.

The implementation contains obtaining of the core configuration by calling function CILcore_getCoreCfg. Then CILspinlock_releaseSpinlock function is called and the result is returned as spinlock state.

Parameters
  • id[in] is used during the system call dispatching

  • spinlockVar[in] variable structure pointer

  • spinlockId[in] spinlock identifier

Returns

CosmOS_SpinlockStateType

CosmOS_SpinlockStateType spinlock_trySpinlock(BitWidthType spinlockId)

Try to get spinlock. DEMO.

The implementation contains obtaining of the operating system and core configuration by calling functions os_getOsCfg and CILcore_getCoreCfg. Then the operating system configuration in function os_getOsNumberOfSpinlocks to get number of spinlocks. The input element id argument is then checked againts the number of spinlock, if it is greater than number of spinlocks SPINLOCK_STATE_ENUM__ERROR_INVALID_ID is returned. Spinlock variable is then obtained based on the id argument by the function os_getOsSpinlockVar. Then the function cosmosApiInternal_spinlock_trySpinlockInternal is called if the core is in the privileged mode or spinlock_trySpinlockInternal is called try to get spinlock and result is then returned as spinlock state. The if condition is implemented to check if the result from cosmosApiInternal_spinlock_trySpinlockInternal is equal to the SPINLOCK_STATE_ENUM__SUCCESSFULLY_LOCKED and if yes the schedulable owner member in spinlock variable is set to the schedulable in execution.

Parameters

spinlockId[in] spinlock identifier

Returns

CosmOS_SpinlockStateType

CosmOS_SpinlockStateType spinlock_releaseSpinlock(BitWidthType spinlockId)

Release spinlock. DEMO.

The implementation contains obtaining of the operating system and core configuration by calling functions os_getOsCfg and CILcore_getCoreCfg. Then the operating system configuration in function os_getOsNumberOfSpinlocks to get number of spinlocks. The input element id argument is then checked againts the number of spinlock, if it is greater than number of spinlocks SPINLOCK_STATE_ENUM__ERROR_INVALID_ID is returned. Spinlock variable is then obtained based on the id argument by the function os_getOsSpinlockVar. The the boolean is obtained by calling function spinlock_ownsSchedulableSpinlock to know if the requesting schedulable owns the spinlock which means if the schedulable locked the spinlock before. The spinlock member of the spinlock variable structure is compared in the implemented if condition that checks if the spinlock is equal to the state SPINLOCK_STATE_ENUM__OCCUPIED otherwise the spinlock state is returned with the value SPINLOCK_STATE_ENUM__ERROR_NOT_IN_OCCUPIED_STATE. Another nested if condition is implemented to check the obtained boolean variable that stores value if the requesting schedulable owns the spinlock. If yes the cosmosApiInternal_spinlock_releaseSpinlockInternal function is called if the core is in the privileged mode or spinlock_releaseSpinlockInternal is called and the result is returned as spinlock state. Otherwise the spinlock state is SPINLOCK_STATE_ENUM__ERROR_SCHEDULABLE_IS_NOT_OWNER.

Parameters

spinlockId[in] spinlock identifier

Returns

CosmOS_SpinlockStateType

CosmOS_BooleanType spinlock_willCauseDeadlock(CosmOS_CoreConfigurationType *core, CosmOS_SpinlockVariableType *spinlockVar)

Check if the spinlock will ends up in deadlock. DEMO.

Parameters
  • core[in] configuration pointer

  • spinlockVar[in] pointer

Returns

CosmOS_BufferStateType

CosmOS_BooleanType spinlock_ownsSchedulableSpinlock(CosmOS_CoreConfigurationType *core, CosmOS_SpinlockVariableType *spinlockVar)

Check if the schedulable in execution owns the current spinlock.

Parameters
  • core[in] configuration pointer

  • spinlockVar[in] pointer

Returns

CosmOS_BufferStateType