sched: mqueue wait list optimize
This commit is contained in:
parent
838309313e
commit
85d013f69a
@ -85,6 +85,9 @@
|
||||
# define nxmq_pollnotify(msgq, eventset)
|
||||
#endif
|
||||
|
||||
# define MQ_WNELIST(mq) (&((mq)->waitfornotempty))
|
||||
# define MQ_WNFLIST(mq) (&((mq)->waitfornotfull))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Declarations
|
||||
****************************************************************************/
|
||||
@ -94,6 +97,8 @@
|
||||
struct mqueue_inode_s
|
||||
{
|
||||
FAR struct inode *inode; /* Containing inode */
|
||||
dq_queue_t waitfornotempty; /* Task list waiting for not empty */
|
||||
dq_queue_t waitfornotfull; /* Task list waiting for not full */
|
||||
struct list_node msglist; /* Prioritized message list */
|
||||
int16_t maxmsgs; /* Maximum number of messages in the queue */
|
||||
int16_t nmsgs; /* Number of message in the queue */
|
||||
|
@ -138,22 +138,6 @@ dq_queue_t g_pendingtasks;
|
||||
|
||||
dq_queue_t g_waitingforsignal;
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
/* This is the list of all tasks that are blocked waiting for a message
|
||||
* queue to become non-empty.
|
||||
*/
|
||||
|
||||
dq_queue_t g_waitingformqnotempty;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
/* This is the list of all tasks that are blocked waiting for a message
|
||||
* queue to become non-full.
|
||||
*/
|
||||
|
||||
dq_queue_t g_waitingformqnotfull;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PAGING
|
||||
/* This is the list of all tasks that are blocking waiting for a page fill */
|
||||
|
||||
@ -243,12 +227,12 @@ const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] =
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
,
|
||||
{ /* TSTATE_WAIT_MQNOTEMPTY */
|
||||
&g_waitingformqnotempty,
|
||||
TLIST_ATTR_PRIORITIZED
|
||||
(FAR void *)offsetof(struct mqueue_inode_s, waitfornotempty),
|
||||
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_OFFSET
|
||||
},
|
||||
{ /* TSTATE_WAIT_MQNOTFULL */
|
||||
&g_waitingformqnotfull,
|
||||
TLIST_ATTR_PRIORITIZED
|
||||
(FAR void *)offsetof(struct mqueue_inode_s, waitfornotfull),
|
||||
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_OFFSET
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_PAGING
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -178,22 +178,6 @@ extern dq_queue_t g_pendingtasks;
|
||||
|
||||
extern dq_queue_t g_waitingforsignal;
|
||||
|
||||
/* This is the list of all tasks that are blocked waiting for a message
|
||||
* queue to become non-empty.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
extern dq_queue_t g_waitingformqnotempty;
|
||||
#endif
|
||||
|
||||
/* This is the list of all tasks that are blocked waiting for a message
|
||||
* queue to become non-full.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
extern dq_queue_t g_waitingformqnotfull;
|
||||
#endif
|
||||
|
||||
/* This is the list of all tasks that are blocking waiting for a page fill */
|
||||
|
||||
#ifdef CONFIG_PAGING
|
||||
|
Loading…
Reference in New Issue
Block a user