Arquivo msg.h

Propósito

Descreve as estruturas que são usadas pelas subroutines que executam operações de queuagem de mensagens.

Sintaxe

#include < sys/msg.h >

Descrição

O arquivo msg.h define as seguintes constantes, tipos e estruturas simbólicas:

Tipos:

unsigned int  msgqnum_t;
unsigned int  msglen_t;

Constantes Simbólicas:

Item Descrição
MSG_NOERRO sem erro se big message */
MSG_R permissão de leitura */
MSG_W permissão de gravação */
MSG_RWAIT um leitor está à espera de uma mensagem */
MSG_WWAIT um escritor está esperando para enviar */
MSG_STAT Número de bytes a copiar para o comando IPC_STAT
MSGXBUFSIZE o comprimento de tudo, menos mtexto [1] e enchimento
MSG_SYSSPACE para sinalizadores rmsgsnd ()
XMSG para sinalizadores rmsgrcv ()

Há uma estrutura de dados de id de fila msg para cada q no sistema. A estrutura msqid_ds contém os seguintes membros:

struct ipc_perm    msg_perm;           operation permission 
struct
void               *__msg_first;       ptr to first message on q
void               *__msg_last;        ptr to last message on q
unsigned int        __msg_cbytes;      current # bytes on q
msgqnum_t          msg_qnum;           # of messages on q
msglen_t           msg_qbytes;         max # of bytes on q
pid_t              msg_lspid;          pid of last msgsnd
pid_t              msg_lrpid;          pid of last msgrcv
time_t             msg_stime;          last msgsnd time
time_t             msg_rtime;          last msgrcv time
time_t             msg_ctime;          last change time
int                __msg_rwait;        wait list for message
receive
int                __msg_wwait;        wait list for message send
unsigned short     __msg_reqevents;    select/poll requested
events

A estruturação msg_hdr contém os seguintes membros:

time_t             mtime;              time message was sent
uid_t              muid;               author's effective uid
gid_t              mgid;               author's effective gid
pid_t              mpid;               author's process id
mtyp_t             mtype;              message type

Há uma estrutura de msica para cada mensagem que pode estar no sistema. A estrutura da msg contém os seguintes membros:

struct msg         *msg_next;          ptr to next message on q
struct msg_hdr     msg_attr;           message attributes
unsigned int       msg_ts;             message text size
char               *msg_spot;          pointer to message text

A estrutura msgbuf é o modelo de buffer de mensagem do usuário para chamadas de sistema msgsnd e msgrcv e contém os seguintes membros:

mtyp_t             mtype;              message type
char               mtext[1];           message text

A estrutura msgxbuf é o modelo de buffer de mensagem do usuário para a chamada do sistema msgxrcv e contém os seguintes membros:

time_t              mtime;             time message was sent
uid_t               muid;              author's effective uid
gid_t               mgid;              author's effective gid
pid_t               mpid;              author's process id
mtyp_t              mtype;             Message type
char                mtext[1];          Message text

A estrutura msginfo contém os seguintes membros:

int              msgmax,        max message size
int              msgmnb,        max # bytes on queue
int              msgmni,        # of message queue identifiers
int              msgmnm;        max # messages per queue identifier

Os tipos time_t, size_t, off_t, mtyp_t, pid_te gid_t são conforme definidos em <sys/types.h>

As seguintes são declaradas como funções:

int msgget(key_t, int);
int msgrcv(int, void *, size_t, long, int);
int msgsnd(int, const void *, size_t, int);
int msgctl(int, int, struct msqid_ds *);
int msgxrcv(int, struct msgxbuf*, int, long, int);

Além disso, todos os símbolos de <sys/ipc.h> serão definidos quando esse cabeçalho for incluído..