ThreadX:
[C] 纯文本查看 复制代码 typedef struct TX_SEMAPHORE_STRUCT
{
/* Define the semaphore ID used for error checking. */
ULONG tx_semaphore_id;
/* Define the semaphore's name. */
CHAR *tx_semaphore_name;
/* Define the actual semaphore count. A zero means that no semaphore
instance is available. */
ULONG tx_semaphore_count;
/* Define the semaphore suspension list head along with a count of
how many threads are suspended. */
struct TX_THREAD_STRUCT
*tx_semaphore_suspension_list;
UINT tx_semaphore_suspended_count;
/* Define the created list next and previous pointers. */
struct TX_SEMAPHORE_STRUCT
*tx_semaphore_created_next,
*tx_semaphore_created_previous;
#ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
/* Define the number of semaphore puts. */
ULONG tx_semaphore_performance_put_count;
/* Define the number of semaphore gets. */
ULONG tx_semaphore_performance_get_count;
/* Define the number of semaphore suspensions. */
ULONG tx_semaphore_performance_suspension_count;
/* Define the number of semaphore timeouts. */
ULONG tx_semaphore_performance_timeout_count;
#endif
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
/* Define the application callback routine used to notify the application when
the a semaphore is put. */
VOID (*tx_semaphore_put_notify)(struct TX_SEMAPHORE_STRUCT *semaphore_ptr);
#endif
/* Define the port extension in the semaphore control block. This
is typically defined to whitespace in tx_port.h. */
TX_SEMAPHORE_EXTENSION
} TX_SEMAPHORE;
uCOS-III:
[C] 纯文本查看 复制代码 /*
------------------------------------------------------------------------------------------------------------------------
* SEMAPHORES
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_sem { /* Semaphore */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_SEM */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Semaphore Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on semaphore */
#if (OS_CFG_DBG_EN > 0u)
OS_SEM *DbgPrevPtr;
OS_SEM *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_SEM_CTR Ctr;
#if (OS_CFG_TS_EN > 0u)
CPU_TS TS;
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_INT16U SemID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
|