Unix Interprocess Communication Mechanisms in CS240 Part 2: Message Queues

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

what is Internal Structure?

Each message queue has an associated set of attributes, some of which are set when it is created.

2
New cards

What is message queues?

allow processes to exchange data in the form of whole messages asynchronously. No rendezvous required.

<p>allow processes to exchange data in the form of whole messages asynchronously. No rendezvous required.</p>
3
New cards

mq_recieve( )

reads a message from a queue.

4
New cards

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);

5
New cards

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);

6
New cards

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.

7
New cards

To request destruction of the message queue entirely

mq_unlink(qname);

8
New cards

#include

#include

#include

Thit is the file you use in C program for message queues

9
New cards

Uniqueness of Message Queues

Priority Queue

10
New cards

main functions of message queues?

mq_open( )

mq_send( )

mq_recieve( )

mq_close( )

mq_unlink( )

11
New cards

mq_open( )

creates a new message queue or opens an existing queue, returning a message queue descriptor for use in later calls.

12
New cards

mq_send( )

writes a message to a queue

13
New cards

mq_close( )

closes a message queue that the process previously opened.

14
New cards

mq_unlink( )

removes a message queue name and marks the queue for deletion when all processes have closed it.

15
New cards

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;

16
New cards

To close access to the message queue for this process

mq_close(mq)

17
New cards

What does the Message Queue manager do?

18
New cards

Still learning (8)

You've begun learning these terms. Keep up the good work!