mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
mqueue: simplify the mqueue reailize
1. remove descript management in mqueue, save code size 2. use i_ops instead of i_mqueue to remove the dup logic Change-Id: Ie88960e50ddcae9c87977c9ad65a45297c663291 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
+1
-2
@@ -42,7 +42,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include "queue.h"
|
||||
|
||||
/********************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -66,7 +65,7 @@ struct mq_attr
|
||||
|
||||
/* Message queue descriptor */
|
||||
|
||||
typedef FAR struct mq_des *mqd_t;
|
||||
typedef int mqd_t;
|
||||
|
||||
/********************************************************************************
|
||||
* Public Data
|
||||
|
||||
@@ -38,10 +38,6 @@
|
||||
# include <nuttx/semaphore.h>
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
# include <nuttx/mqueue.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -342,9 +338,6 @@ union inode_ops_u
|
||||
#ifdef CONFIG_FS_NAMED_SEMAPHORES
|
||||
FAR struct nsem_inode_s *i_nsem; /* Named semaphore */
|
||||
#endif
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
FAR struct mqueue_inode_s *i_mqueue; /* POSIX message queue */
|
||||
#endif
|
||||
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
|
||||
FAR char *i_link; /* Full path to link target */
|
||||
#endif
|
||||
|
||||
@@ -98,8 +98,6 @@
|
||||
|
||||
/* This structure defines a message queue */
|
||||
|
||||
struct mq_des; /* forward reference */
|
||||
|
||||
struct mqueue_inode_s
|
||||
{
|
||||
FAR struct inode *inode; /* Containing inode */
|
||||
@@ -113,23 +111,11 @@ struct mqueue_inode_s
|
||||
#else
|
||||
uint16_t maxmsgsize; /* Max size of message in message queue */
|
||||
#endif
|
||||
FAR struct mq_des *ntmqdes; /* Notification: Owning mqdes (NULL if none) */
|
||||
pid_t ntpid; /* Notification: Receiving Task's PID */
|
||||
struct sigevent ntevent; /* Notification description */
|
||||
struct sigwork_s ntwork; /* Notification work */
|
||||
};
|
||||
|
||||
/* This describes the message queue descriptor that is held in the
|
||||
* task's TCB
|
||||
*/
|
||||
|
||||
struct mq_des
|
||||
{
|
||||
FAR struct mq_des *flink; /* Forward link to next message descriptor */
|
||||
FAR struct mqueue_inode_s *msgq; /* Pointer to associated message queue */
|
||||
int oflags; /* Flags set when message queue was opened */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -424,69 +410,6 @@ void nxmq_free_msgq(FAR struct mqueue_inode_s *msgq);
|
||||
FAR struct mqueue_inode_s *nxmq_alloc_msgq(mode_t mode,
|
||||
FAR struct mq_attr *attr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxmq_create_des
|
||||
*
|
||||
* Description:
|
||||
* Create a message queue descriptor for the specified TCB
|
||||
*
|
||||
* Input Parameters:
|
||||
* TCB - task that needs the descriptor.
|
||||
* msgq - Named message queue containing the message
|
||||
* oflags - access rights for the descriptor
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the message queue descriptor is returned. NULL is returned
|
||||
* on a failure to allocate.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
mqd_t nxmq_create_des(FAR struct tcb_s *mtcb,
|
||||
FAR struct mqueue_inode_s *msgq, int oflags);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxmq_close_group
|
||||
*
|
||||
* Description:
|
||||
* This function is used to indicate that all threads in the group are
|
||||
* finished with the specified message queue mqdes. nxmq_close_group()
|
||||
* deallocates any system resources allocated by the system for use by
|
||||
* this task for its message queue.
|
||||
*
|
||||
* Input Parameters:
|
||||
* mqdes - Message queue descriptor.
|
||||
* group - Group that has the open descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) if the message queue is closed successfully. Otherwise, a
|
||||
* negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxmq_close_group(mqd_t mqdes, FAR struct task_group_s *group);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxmq_desclose_group
|
||||
*
|
||||
* Description:
|
||||
* This function performs the portion of the mq_close operation related
|
||||
* to freeing resource used by the message queue descriptor itself.
|
||||
*
|
||||
* Input Parameters:
|
||||
* mqdes - Message queue descriptor.
|
||||
* group - Group that has the open descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* and failure.
|
||||
*
|
||||
* Assumptions:
|
||||
* - Called only from mq_close() with the scheduler locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxmq_desclose_group(mqd_t mqdes, FAR struct task_group_s *group);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
||||
#include <pthread.h>
|
||||
#include <mqueue.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
@@ -601,12 +600,6 @@ struct task_group_s
|
||||
struct socketlist tg_socketlist; /* Maps socket descriptor to socket */
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DISABLE_MQUEUE
|
||||
/* POSIX Named Message Queue Fields *******************************************/
|
||||
|
||||
sq_queue_t tg_msgdesq; /* List of opened message queues */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Address Environment ********************************************************/
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <strings.h>
|
||||
#include "queue.h"
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user