MESSAGE QUEUES
message queues are like pipes, only difference is that in pipes data go byte by byte. but in message queues ,message go block by block.
message queues use user free space.
message have 2 parts—
1. contol
2.data
BLOCK is define as-
struct_msg
{
unsigned long type;
char *payload;
};
where type is process pid
payload is message.
In message queues, both sender and receiver are independent of each other.
MSGMAX——-maximum size of payload
MSGMNB——-maximum number of blocks
1. msgget–
int msgget(key_t key,int msgflg);
2. msgctl—-
int msgctl(int msqid,
int command,
struct msqid_ds *buf);
commands are——
IPC_STAT—structure initialized
IPC_SET—-assigne value to message queqe
IPC_RMID—delete message queue
3. msgsend
int msgsend( int msqid,
const void *msg_ptr,
size_t msg_sz,
int msgflg,);