hi, I'm looking for 'struct os_**_cb ', such as 'struct os_mutex_cb' from the source code of CMSIS-RTOS, but just cannot find it.
'struct os_**_cb ' is used in os_cmsis.h, and I know they are implementation specific in every CMSIS-RTOS, but they are not defined in rt_CMSIS.c or any other files.
So , where are they defined in RTX?
so i wonder why not just use 'void *osSemaphoreId' to replace 'typedef struct os_semaphore_cb *osSemaphoreId' ? what's taken into consideration here?
**** This is my guess as to why void* was not used and whey os_semaphore_cb* osSempahoreId is "better"
The reason it was written this way was to make it "easier" to understand (I would not use the term easy here)
void* tells you almost nothing about a variable (pointer, but no idea of pointer to what)
typedef struct os_semaphore_cb *osSemaphoreId DOES give you some information and maybe a place to look for more information. Your point of it not being any more specific about the type than void* is true, but the os_semaphore_cb more easily gets me to the #define that has:
uint32_t os_semaphore_cb_##name[2] = { 0 };
BUT add the the following very helpful comment -
/// Semaphore ID identifies the semaphore (pointer to a semaphore control block). typedef struct os_semaphore_cb *osSemaphoreId;
Semaphore Control Block is a term used in RTX. As it turns out osSemaphoreId is a pointer to an RTX Semaphore Control Block (OS_SCB is defined in rt_typedef.h)
Thanks, Robert and Per . I now somewhat understand it. it's designed for both readability and safety considerations.