|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Two-level bitmap for more priority levels than a native integer can hold (BITS is a multiple of 32 above 64, e.g. 96, 128, ..., 1024). More...
#include <stk_priority_bitmap.h>
Public Types | |
| enum | { CAPACITY = BITS , WORDS = (BITS / 32U) } |
Public Member Functions | |
| STK_STATIC_ASSERT_DESC_N (Multiple32,(BITS % 32U)==0U, "PriorityBitmap: BITS must be a multiple of 32") | |
| STK_STATIC_ASSERT_DESC_N (Min32, BITS >=32U, "PriorityBitmap: BITS must be at least 32") | |
| STK_STATIC_ASSERT_DESC_N (Max1024, BITS<=1024U, "PriorityBitmap: BITS must not exceed 1024 (32-bit summary)") | |
| PriorityBitmap () | |
| Construct an empty bitmap. | |
| __stk_forceinline void | Set (uint32_t bit) |
| Set bit bit, [0, BITS). | |
| __stk_forceinline void | Clear (uint32_t bit) |
| Clear bit bit, [0, BITS). | |
| __stk_forceinline bool | IsSet (uint32_t bit) const |
| Check that bit bit is set, [0, BITS). | |
| __stk_forceinline bool | IsEmpty () const |
| Check that no bit is set. | |
| __stk_forceinline uint32_t | HighestSet () const |
| Index of the most significant set bit. | |
Private Attributes | |
| uint32_t | m_summary |
| Bit w set when m_words[w] != 0. | |
| uint32_t | m_words [WORDS] |
| Level 0: the bits. | |
Two-level bitmap for more priority levels than a native integer can hold (BITS is a multiple of 32 above 64, e.g. 96, 128, ..., 1024).
Level 0 is an array of BITS / 32 words (bit i lives in word i / 32, position i % 32). Level 1 is a single 32-bit summary word where bit w is set if and only if word w is non-zero. The summary keeps every operation O(1) regardless of BITS:
| BITS | Number of bits. Must be a multiple of 32 and at most 1024 (32 words, the summary width). Any such value works (32 and 64 too), but plain uint32_t / uint64_t are cheaper for up to 64 priorities. |
Definition at line 140 of file stk_priority_bitmap.h.
| anonymous enum |
| Enumerator | |
|---|---|
| CAPACITY | Number of bits. |
| WORDS | Number of 32-bit words. |
Definition at line 147 of file stk_priority_bitmap.h.
|
inline |
Construct an empty bitmap.
Definition at line 154 of file stk_priority_bitmap.h.
|
inline |
Clear bit bit, [0, BITS).
Definition at line 169 of file stk_priority_bitmap.h.
|
inline |
Index of the most significant set bit.
Definition at line 198 of file stk_priority_bitmap.h.
|
inline |
Check that no bit is set.
Definition at line 192 of file stk_priority_bitmap.h.
|
inline |
Check that bit bit is set, [0, BITS).
Definition at line 184 of file stk_priority_bitmap.h.
|
inline |
| stk::sched::PriorityBitmap< BITS >::STK_STATIC_ASSERT_DESC_N | ( | Max1024 | , |
| BITS<= | 1024U, | ||
| "PriorityBitmap< BITS >: BITS must not exceed 1024 (32-bit summary)" | ) |
| stk::sched::PriorityBitmap< BITS >::STK_STATIC_ASSERT_DESC_N | ( | Min32 | , |
| BITS >= | 32U, | ||
| "PriorityBitmap< BITS >: BITS must be at least 32" | ) |
| stk::sched::PriorityBitmap< BITS >::STK_STATIC_ASSERT_DESC_N | ( | Multiple32 | , |
| (BITS % 32U) | = =0U, | ||
| "PriorityBitmap< BITS >: BITS must be a multiple of 32" | ) |
|
private |
Bit w set when m_words[w] != 0.
Definition at line 210 of file stk_priority_bitmap.h.
|
private |
Level 0: the bits.
Definition at line 211 of file stk_priority_bitmap.h.