|
结构体:
- /// OS Runtime Information structure
- typedef struct {
- const char *os_id; ///< OS Identification
- uint32_t version; ///< OS Version
- struct { ///< Kernel Info
- uint8_t state; ///< State
- volatile uint8_t blocked; ///< Blocked
- uint8_t pendSV; ///< Pending SV
- uint8_t reserved;
- uint32_t tick; ///< Tick counter
- } kernel;
- int32_t tick_irqn; ///< Tick Timer IRQ Number
- struct { ///< Thread Info
- struct { ///< Thread Run Info
- osRtxThread_t *curr; ///< Current running Thread
- osRtxThread_t *next; ///< Next Thread to Run
- } run;
- osRtxObject_t ready; ///< Ready List Object
- osRtxThread_t *idle; ///< Idle Thread
- osRtxThread_t *delay_list; ///< Delay List
- osRtxThread_t *wait_list; ///< Wait List (no Timeout)
- osRtxThread_t *terminate_list; ///< Terminate Thread List
- struct { ///< Thread Round Robin Info
- osRtxThread_t *thread; ///< Round Robin Thread
- uint32_t tick; ///< Round Robin Time Tick
- uint32_t timeout; ///< Round Robin Timeout
- } robin;
- } thread;
- struct { ///< Timer Info
- osRtxTimer_t *list; ///< Active Timer List
- osRtxThread_t *thread; ///< Timer Thread
- osRtxMessageQueue_t *mq; ///< Timer Message Queue
- void (*tick)(void); ///< Timer Tick Function
- } timer;
- struct { ///< ISR Post Processing Queue
- uint16_t max; ///< Maximum Items
- uint16_t cnt; ///< Item Count
- uint16_t in; ///< Incoming Item Index
- uint16_t out; ///< Outgoing Item Index
- void **data; ///< Queue Data
- } isr_queue;
- struct { ///< ISR Post Processing functions
- void (*thread)(osRtxThread_t*); ///< Thread Post Processing function
- void (*event_flags)(osRtxEventFlags_t*); ///< Event Flags Post Processing function
- void (*semaphore)(osRtxSemaphore_t*); ///< Semaphore Post Processing function
- void (*memory_pool)(osRtxMemoryPool_t*); ///< Memory Pool Post Processing function
- void (*message)(osRtxMessage_t*); ///< Message Post Processing function
- } post_process;
- struct { ///< Memory Pools (Variable Block Size)
- void *stack; ///< Stack Memory
- void *mp_data; ///< Memory Pool Data Memory
- void *mq_data; ///< Message Queue Data Memory
- void *common; ///< Common Memory
- } mem;
- struct { ///< Memory Pools (Fixed Block Size)
- osRtxMpInfo_t *stack; ///< Stack for Threads
- osRtxMpInfo_t *thread; ///< Thread Control Blocks
- osRtxMpInfo_t *timer; ///< Timer Control Blocks
- osRtxMpInfo_t *event_flags; ///< Event Flags Control Blocks
- osRtxMpInfo_t *mutex; ///< Mutex Control Blocks
- osRtxMpInfo_t *semaphore; ///< Semaphore Control Blocks
- osRtxMpInfo_t *memory_pool; ///< Memory Pool Control Blocks
- osRtxMpInfo_t *message_queue; ///< Message Queue Control Blocks
- } mpi;
- } osRtxInfo_t;
复制代码
使用举例:
memset(&osRtxInfo.kernel, 0, sizeof(osRtxInfo) - offsetof(osRtxInfo_t, kernel));
原始定义:
- #ifdef __clang__
- #define offsetof(t, d) __builtin_offsetof(t, d)
- #else
- /* EDG uses __INTADDR__ to avoid errors when strict */
- #define offsetof(t, memb) ((__CLIBNS size_t)__INTADDR__(&(((t *)0)->memb)))
- #endif
复制代码
|
|