更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
mqueue.h 文件参考

浏览源代码.

结构体

union  send_receive_t
 
struct  mqnotify
 
struct  mqarray
 
struct  mqpersonal
 
struct  mq_attr
 

类型定义

typedef union send_receive_t mode_s
 
typedef UINTPTR mqd_t
 

函数

mqd_t mq_open (const char *mqName, int openFlag,...)
 
int mq_close (mqd_t personal)
 
int mq_unlink (const char *mqName)
 
int mq_send (mqd_t personal, const char *msg, size_t msgLen, unsigned int msgPrio)
 
ssize_t mq_receive (mqd_t personal, char *msg, size_t msgLen, unsigned int *msgPrio)
 
int mq_getsetattr (mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr *MqOldAttr)
 
int mq_timedsend (mqd_t personal, const char *msg, size_t msgLen, unsigned int msgPrio, const struct timespec *absTimeout)
 
ssize_t mq_timedreceive (mqd_t personal, char *msg, size_t msgLen, unsigned int *msgPrio, const struct timespec *absTimeout)
 
void MqueueRefer (int sysFd)
 
int OsMqNotify (mqd_t personal, const struct sigevent *sigev)
 

类型定义说明

◆ mode_s

typedef union send_receive_t mode_s

函数说明

◆ MqueueRefer()

void MqueueRefer ( int  sysFd)

在文件 mqueue.c339 行定义.

340{
341 struct mqarray *mqueueCB = NULL;
342 struct mqpersonal *privateMqPersonal = NULL;
343
345 /* Get the personal sysFd and reset personal fd -1 */
346 privateMqPersonal = MqGetPrivDataBuff((mqd_t)sysFd);
347 if (privateMqPersonal == NULL) {
348 goto OUT_UNLOCK;
349 }
350 mqueueCB = privateMqPersonal->mq_posixdes;
351 if (mqueueCB == NULL) {
352 goto OUT_UNLOCK;
353 }
354
355 privateMqPersonal->mq_refcount++;
356OUT_UNLOCK:
358 return;
359}
UINTPTR mqd_t
Definition: mqueue.h:127
STATIC pthread_mutex_t g_mqueueMutex
Definition: mqueue.c:54
STATIC struct mqpersonal * MqGetPrivDataBuff(mqd_t personal)
Definition: mqueue.c:290
int pthread_mutex_lock(pthread_mutex_t *mutex)
互斥锁加锁操作
int pthread_mutex_unlock(pthread_mutex_t *mutex)
解锁互斥锁
Definition: mqueue.h:90
struct mqarray * mq_posixdes
Definition: mqueue.h:104
UINT32 mq_refcount
Definition: mqueue.h:109
函数调用图:
这是这个函数的调用关系图:

◆ OsMqNotify()

int OsMqNotify ( mqd_t  personal,
const struct sigevent *  sigev 
)

在文件 mqueue.c891 行定义.

892{
893 struct mqarray *mqueueCB = NULL;
894 struct mqnotify *mqnotify = NULL;
895 struct mqpersonal *privateMqPersonal = NULL;
896
897 if (!MqNotifyParamCheck(personal, sigev)) {
898 goto ERROUT;
899 }
900
902 privateMqPersonal = MqGetPrivDataBuff(personal);
903 if (privateMqPersonal == NULL) {
904 goto OUT_UNLOCK;
905 }
906
907 if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
908 errno = EBADF;
909 goto OUT_UNLOCK;
910 }
911
912 mqueueCB = privateMqPersonal->mq_posixdes;
913 mqnotify = &mqueueCB->mq_notify;
914
915 if (sigev == NULL) {
917 mqnotify->pid = 0;
918 }
919 } else if (mqnotify->pid != 0) {
920 errno = EBUSY;
921 goto OUT_UNLOCK;
922 } else {
923 switch (sigev->sigev_notify) {
924 case SIGEV_NONE:
925 mqnotify->notify.sigev_notify = SIGEV_NONE;
926 break;
927 case SIGEV_SIGNAL:
928 mqnotify->notify.sigev_signo = sigev->sigev_signo;
929 mqnotify->notify.sigev_value = sigev->sigev_value;
930 mqnotify->notify.sigev_notify = SIGEV_SIGNAL;
931 break;
932 default:
933 break;
934 }
935
937 }
938
940 return 0;
941OUT_UNLOCK:
943ERROUT:
944 return -1;
945}
LITE_OS_SEC_TEXT UINT32 LOS_GetCurrProcessID(VOID)
获取当前进程的进程ID
Definition: los_process.c:2161
STATIC INLINE BOOL MqNotifyParamCheck(mqd_t personal, const struct sigevent *sigev)
Definition: mqueue.c:868
struct mqnotify mq_notify
Definition: mqueue.h:98
pid_t pid
Definition: mqueue.h:85
struct sigevent notify
Definition: mqueue.h:86
UINT32 mq_status
Definition: mqueue.h:108
函数调用图:
这是这个函数的调用关系图: