SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
__lock Struct Reference

Lock object behind Newlib's opaque _LOCK_T (struct __lock *). More...

Collaboration diagram for __lock:

Public Types

enum  EKind : uint8_t {
  KIND_NONE = 0 ,
  KIND_PLAIN ,
  KIND_RECURSIVE
}

Public Attributes

EKind kind
 kind of the constructed mutex
bool dynamic
 true if taken from the lock pool by __retarget_lock_init* (and therefore returned by close)
stk::IMutex * mutex
 constructed FastMutex (KIND_PLAIN) or Mutex (KIND_RECURSIVE), otherwise nullptr
uint8_t storage [STORAGE_SIZE]

Static Public Attributes

static const size_t STORAGE_SIZE
 storage large enough for either mutex type

Detailed Description

Lock object behind Newlib's opaque _LOCK_T (struct __lock *).

Holds either a FastMutex (plain lock) or a Mutex (recursive lock), constructed in-place in storage. The same layout serves dynamic locks (taken from the static lock pool by __retarget_lock_init*) and Newlib's static locks (zero-initialized BSS objects, constructed lazily on first use).

Definition at line 43 of file stk_newlib.cpp.

Member Enumeration Documentation

◆ EKind

enum __lock::EKind : uint8_t
Enumerator
KIND_NONE 

not constructed (zero-initialized static lock)

KIND_PLAIN 

FastMutex.

KIND_RECURSIVE 

Mutex.

Definition at line 45 of file stk_newlib.cpp.

46 {
47 KIND_NONE = 0,
50 };
@ KIND_RECURSIVE
Mutex.
@ KIND_PLAIN
FastMutex.
@ KIND_NONE
not constructed (zero-initialized static lock)

Member Data Documentation

◆ dynamic

bool __lock::dynamic

true if taken from the lock pool by __retarget_lock_init* (and therefore returned by close)

Definition at line 57 of file stk_newlib.cpp.

◆ kind

EKind __lock::kind

kind of the constructed mutex

Definition at line 56 of file stk_newlib.cpp.

◆ mutex

stk::IMutex* __lock::mutex

constructed FastMutex (KIND_PLAIN) or Mutex (KIND_RECURSIVE), otherwise nullptr

Definition at line 58 of file stk_newlib.cpp.

◆ storage

uint8_t __lock::storage[STORAGE_SIZE]

Definition at line 60 of file stk_newlib.cpp.

◆ STORAGE_SIZE

const size_t __lock::STORAGE_SIZE
static
Initial value:
= (sizeof(stk::sync::FastMutex) > sizeof(stk::sync::Mutex)) ?
Non-recursive (binary) mutex primitive with ownership tracking.
Recursive mutex primitive that allows the same thread to acquire the lock multiple times.

storage large enough for either mutex type

Definition at line 53 of file stk_newlib.cpp.


The documentation for this struct was generated from the following file: