sched: mqueue wait list optimize

This commit is contained in:
zhangyuan21
2022-09-09 14:26:43 +08:00
committed by Xiang Xiao
parent 838309313e
commit 85d013f69a
6 changed files with 16 additions and 48 deletions
+3
View File
@@ -101,6 +101,9 @@ int nxmq_alloc_msgq(FAR struct mq_attr *attr,
#ifndef CONFIG_DISABLE_MQUEUE_NOTIFICATION
msgq->ntpid = INVALID_PROCESS_ID;
#endif
dq_init(&msgq->waitfornotempty);
dq_init(&msgq->waitfornotfull);
}
else
{
+2 -6
View File
@@ -280,16 +280,12 @@ ssize_t nxmq_do_receive(FAR struct mqueue_inode_s *msgq,
if (msgq->nwaitnotfull > 0)
{
/* Find the highest priority task that is waiting for
* this queue to be not-full in g_waitingformqnotfull list.
* this queue to be not-full in waitfornotfull list.
* This must be performed in a critical section because
* messages can be sent from interrupt handlers.
*/
for (btcb = (FAR struct tcb_s *)g_waitingformqnotfull.head;
btcb && btcb->waitobj != msgq;
btcb = btcb->flink)
{
}
btcb = (FAR struct tcb_s *)dq_peek(MQ_WNFLIST(msgq));
/* If one was found, unblock it. NOTE: There is a race
* condition here: the queue might be full again by the
+2 -6
View File
@@ -389,17 +389,13 @@ int nxmq_do_send(FAR struct mqueue_inode_s *msgq,
if (msgq->nwaitnotempty > 0)
{
/* Find the highest priority task that is waiting for
* this queue to be non-empty in g_waitingformqnotempty
* this queue to be non-empty in waitfornotempty
* list. leave_critical_section() should give us sufficient
* protection since interrupts should never cause a change
* in this list
*/
for (btcb = (FAR struct tcb_s *)g_waitingformqnotempty.head;
btcb && btcb->waitobj != msgq;
btcb = btcb->flink)
{
}
btcb = (FAR struct tcb_s *)dq_peek(MQ_WNELIST(msgq));
/* If one was found, unblock it */