An OS_CRIT object is used to establish critical sections of code that can only be run by one task at a time. Tasks that try to claim a critical section which is currently claimed by another task will stop and wait for that task to release the critical section before continuing execution.
More...
#include <nbrtos.h>
Inherits OS_TASK_DLY_OBJ.
|
| OS_CRIT () |
| Create and initialize an OS_CRIT object.
|
|
uint8_t | Init () |
| Initialize an OS_CRIT object to its default state.
|
|
uint8_t | LockAndEnter (uint32_t timeoutTicks=WAIT_FOREVER) |
| Locks the current task to prevent task switching and claims the critical section.
|
|
uint8_t | Enter (TickTimeout &t) |
| Request to Enter/Claim the critical section.
|
|
uint8_t | Enter (uint32_t timeoutTicks=WAIT_FOREVER) |
| Request to Enter/Claim the critical section, with a time out parameter.
|
|
uint8_t | EnterNoWait () |
| Request to Enter/Claim the critical section. Does not wait if a critical section is not available.
|
|
uint8_t | Leave () |
| Release the critical section.
|
|
uint8_t | LeaveAndUnlock () |
| Leave/release the critical section and unlock the task.
|
|
bool | UsedFromISR () |
| Check if critical section UsedFromISR flag is set.
|
|
void | SetUseFromISR (bool enableFromISR) |
| Set critical section UsedFromISR flag.
|
|
bool | OwnedByCurTask () |
| Check if critical section owned by the current task.
|
|
uint32_t | CurDepth () |
| Returns the critical section depth count.
|
|
|
void | ForceReboot (bool fromIRQ) |
| Forces the system hardware to perform a soft reset.
|
|
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at a time. Tasks that try to claim a critical section which is currently claimed by another task will stop and wait for that task to release the critical section before continuing execution.
◆ OS_CRIT()
◆ CurDepth()
uint32_t OS_CRIT::CurDepth |
( |
| ) |
|
|
inline |
Returns the critical section depth count.
- Returns
- Depth count value
◆ Enter() [1/2]
Request to Enter/Claim the critical section.
- Note
- You must call Leave() once for each successful Enter() call to release the critical section so that another task can run it.
- Parameters
-
t | The number of TickTimeout time ticks to wait for the critical section. A timeout of 0 (zero) waits forever. |
- Return values
-
OS_NO_ERR | If we were successful in claiming the critical section or if our task owns it |
OS_TIMEOUT | If we were unable to claim the section NBRTOS Error Codes |
- See also
- NBRTOS Error Codes, EnterNoWait(), Leave()
◆ Enter() [2/2]
uint8_t OS_CRIT::Enter |
( |
uint32_t | timeoutTicks = WAIT_FOREVER | ) |
|
|
inline |
Request to Enter/Claim the critical section, with a time out parameter.
- Note
- You must call Leave() once for each successful Enter() call to release the critical section so that another task can run it.
- Parameters
-
timeoutTicks | The number of sytem TimeTicks to wait for the critical section. A timeout of 0 (zero) waits forever. |
- Return values
-
OS_NO_ERR | If we were successful in claiming the critical section or if our task owns it |
OS_TIMEOUT | If we were unable to claim the section NBRTOS Error Codes |
- See also
- NBRTOS Error Codes, EnterNoWait(), Leave()
◆ EnterNoWait()
uint8_t OS_CRIT::EnterNoWait |
( |
| ) |
|
Request to Enter/Claim the critical section. Does not wait if a critical section is not available.
- Note
- You must call Leave() once for each successful Enter() call to release the critical section so that another task can run it.
- Return values
-
OS_NO_ERR | If we were successful in claiming the critical section or if our task owns it |
OS_TIMEOUT | If we were unable to claim the section NBRTOS Error Codes |
- See also
- NBRTOS Error Codes, Enter(), Leave()
◆ Init()
uint8_t OS_CRIT::Init |
( |
| ) |
|
◆ Leave()
uint8_t OS_CRIT::Leave |
( |
| ) |
|
Release the critical section.
- Note
- This function must be called once for each successful Enter() or EnterNoWait() call to release the critical section so another task can run it.
- Return values
-
OS_NO_ERR | If we were successful in claiming the critical section or if our task owns it |
OS_CRIT_ERR | If we are trying to release a critical section that we do not own NBRTOS Error Codes |
- See also
- NBRTOS Error Codes, Enter(), EnterNoWait()
◆ LeaveAndUnlock()
uint8_t OS_CRIT::LeaveAndUnlock |
( |
| ) |
|
◆ LockAndEnter()
uint8_t OS_CRIT::LockAndEnter |
( |
uint32_t | timeoutTicks = WAIT_FOREVER | ) |
|
Locks the current task to prevent task switching and claims the critical section.
- Note
- If it is unable to claim the critical section and times out, then the lock will be released. Otherwise LeaveAndUnlock() must be called once for each successful LockAndEnter() call to both unlock and release the critical section so that another task might run it.
- Parameters
-
timeoutTicks | The number of TickTimeout time ticks to wait for the critical section. A timeout of 0 (zero) waits forever. |
- Return values
-
OS_NO_ERR | If we were successful in claiming the critical section or if our task owns it |
OS_TIMEOUT | If we were unable to claim the section |
- See also
- NBRTOS Error Codes, LeaveAndUnlock(), Enter()
◆ SetUseFromISR()
void OS_CRIT::SetUseFromISR |
( |
bool | enableFromISR | ) |
|
|
inline |
Set critical section UsedFromISR flag.
- Parameters
-
enableFromISR | Set true to set flag |
- See also
- UsedFromISR()
◆ UsedFromISR()
bool OS_CRIT::UsedFromISR |
( |
| ) |
|
|
inline |
The documentation for this struct was generated from the following file: