Bonus Tasks: Inter-Process Communication. Message Queue.
Tasks
Make the 09_IPC2 directory and store code there.
Use examples on message queues from the lecture.
- Write a program
sendmq.cthat sends a message with priority1through the specified queue:./sendmq /queue Messageshould send a message"Message"to queue"/queue"with priority 1;- you may also copy+paste and test other lecture examples:
- queue creation;
- message receiving;
- queue unlinking.
- Write a “messaging server”
mqserver.cthat constantly waits on message queue and prints every message received:- create a queue;
- wait for the message and receive it;
- if this message is not equal to string
"QUIT"(i.e. 5 bytes: ‘Q’, ‘U’, ‘I’, ‘T’, and 0), then print it and return to the previous step; - stop receiving and unlink the queue if message is string
"QUIT".
- Modify server to catch
SIGINT. Name resulting programmqsignal.c:- so when pressing
Control+Cthe program should stop reading messages, unlink the queue and stop; - check every function called for possible errors.
- so when pressing