System V IPC 之消息队列

消息队列和共享内存、信号量一样,同属 System V IPC 通信机制。消息队列是一系列连续排列的消息,保存在内核中,通过消息队列的引用标识符来访问。使用消息队列的好处是对每个消息指定了特定消息类型,接收消息的进程可以请求接收下一条消息,也可以请求接收下一条特定类型的消息。

相关数据结构

与其他两个 System V IPC 通信机制一样,消息队列也有一个与之对应的结构,该结构的定义如下:

struct msqid_ds { struct ipc_perm msq_perm; struct msg *msg_first; struct msg *msg_last; ulong msg_ctypes; ulong msg_qnum; ulong msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; time_t msg_stime; time_t msg_rtime; time_t msg_ctime; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwdspp.html