Skip to content

Commit c306bc7

Browse files
author
Don Dominic
committed
feat: add task message queue check API
Add a new API to check if the task message queue is full or not. Signed-off-by: Don Dominic <[email protected]>
1 parent 8c596b9 commit c306bc7

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

Source/os.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,7 @@ void OSTaskQPost (OS_TCB *p_tcb,
16721672
OS_OPT opt,
16731673
OS_ERR *p_err);
16741674

1675+
CPU_BOOLEAN OSTaskQIsFull (OS_TCB *p_tcb);
16751676
#endif
16761677

16771678
#if (OS_CFG_TASK_REG_TBL_SIZE > 0u)
@@ -2010,6 +2011,8 @@ void OS_MsgQPut (OS_MSG_Q *p_msg_q,
20102011
CPU_TS ts,
20112012
OS_ERR *p_err);
20122013

2014+
CPU_BOOLEAN OS_MsgQIsFull (OS_MSG_Q *p_msg_q);
2015+
20132016
/* ---------------------------------------------- PEND/POST MANAGEMENT ---------------------------------------------- */
20142017

20152018
void OS_Pend (OS_PEND_OBJ *p_obj,

Source/os_msg.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,30 @@ void OS_MsgQPut (OS_MSG_Q *p_msg_q,
346346
#endif
347347
*p_err = OS_ERR_NONE;
348348
}
349+
350+
351+
/*
352+
************************************************************************************************************************
353+
* CHECK MESSAGE QUEUE
354+
*
355+
* Description: This function checks if the message queue is full or not
356+
*
357+
* Arguments : p_msg_q is a pointer to the message queue
358+
* -------
359+
*
360+
* Returns : == OS_FALSE if message queue is not full.
361+
* == OS_TRUE if message queue is full.
362+
*
363+
* Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
364+
************************************************************************************************************************
365+
*/
366+
367+
CPU_BOOLEAN OS_MsgQIsFull (OS_MSG_Q *p_msg_q)
368+
{
369+
if (p_msg_q->NbrEntries >= p_msg_q->NbrEntriesSize) {
370+
return(OS_TRUE);
371+
} else {
372+
return(OS_FALSE);
373+
}
374+
}
349375
#endif

Source/os_task.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,34 @@ void OSTaskQPost (OS_TCB *p_tcb,
11701170
#endif
11711171

11721172

1173+
/*
1174+
************************************************************************************************************************
1175+
* TASK MESSAGE Q CHECK
1176+
*
1177+
* Description: This function checks if the task message queue is full or not.
1178+
*
1179+
* Arguments : p_tcb is a pointer to the TCB of the task. If you specify a NULL pointer then the check is
1180+
* performed for the queue of the calling task.
1181+
*
1182+
* Returns : == OS_FALSE if task message queue is not full.
1183+
* == OS_TRUE if task message queue is full.
1184+
*
1185+
* Note(s) : none
1186+
************************************************************************************************************************
1187+
*/
1188+
1189+
#if (OS_CFG_TASK_Q_EN > 0u)
1190+
CPU_BOOLEAN OSTaskQIsFull (OS_TCB *p_tcb)
1191+
{
1192+
if (p_tcb == (OS_TCB *)0) { /* Check for 'self'? */
1193+
p_tcb = OSTCBCurPtr;
1194+
}
1195+
1196+
return (OS_MsgQIsFull(&p_tcb->MsgQ));
1197+
}
1198+
#endif
1199+
1200+
11731201
/*
11741202
************************************************************************************************************************
11751203
* GET THE CURRENT VALUE OF A TASK REGISTER

0 commit comments

Comments
 (0)