1/17
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
what is Internal Structure?
Each message queue has an associated set of attributes, some of which are set when it is created.
What is message queues?
allow processes to exchange data in the form of whole messages asynchronously. No rendezvous required.
mq_recieve( )
reads a message from a queue.
Creating a message queue
If the message queue doesn't exist, additional parameters are supplied to mq_open
mqd_t mq;
mq = mq_open(qname, modeflags, permissions, &attr);
If the message queue already exists it can be opened with
modeflags = O_RDWR;
mq = mq_open(qname, modeflags);
Sending a message to an opened message queue mq
char buffer[max_size];
int priority = 0;
memset(buffer,0, max_size);
strcpy(buffer,"Hello There");
mq_send(mq, buffer, max_size, priority);
Reading a message from an opened message queue
int numRead;
char buffer[max_size];
int priority;
numRead = mq_receive(mq, buffer, max_size, &priority);
numRead is the number of bytes in the received message.
To request destruction of the message queue entirely
mq_unlink(qname);
#include
#include
#include
Thit is the file you use in C program for message queues
Uniqueness of Message Queues
Priority Queue
main functions of message queues?
mq_open( )
mq_send( )
mq_recieve( )
mq_close( )
mq_unlink( )
mq_open( )
creates a new message queue or opens an existing queue, returning a message queue descriptor for use in later calls.
mq_send( )
writes a message to a queue
mq_close( )
closes a message queue that the process previously opened.
mq_unlink( )
removes a message queue name and marks the queue for deletion when all processes have closed it.
Creating a new message queue
strcpy(qname, "/test_queue");
/ the flag O_CREAT is for creating a message queue if it doesn't exist on opening /
modeflags = O_RDWR | O_CREAT;
/ Read/Write perm for owner only /
permissions = 0600;
attr.mq_flags = 0; /Blocking semantics mode/
attr.mq_maxmsg = 10;
attr.mq_msgsize = 512;
To close access to the message queue for this process
mq_close(mq)
What does the Message Queue manager do?
Still learning (8)
You've begun learning these terms. Keep up the good work!