mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
sched: mqueue wait list optimize
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user