View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

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.

  1. Write a program sendmq.c that sends a message with priority 1 through the specified queue:
    1. ./sendmq /queue Message should send a message "Message" to queue "/queue" with priority 1;
    2. you may also copy+paste and test other lecture examples:
      • queue creation;
      • message receiving;
      • queue unlinking.
  2. Write a “messaging server” mqserver.c that constantly waits on message queue and prints every message received:
    1. create a queue;
    2. wait for the message and receive it;
    3. 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;
    4. stop receiving and unlink the queue if message is string "QUIT".
  3. Modify server to catch SIGINT. Name resulting program mqsignal.c:
    1. so when pressing Control+C the program should stop reading messages, unlink the queue and stop;
    2. check every function called for possible errors.