Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Read the section that addresses message queues in the lab manual. 2 . Read the manual pages of the following systems calls: #include

1. Read the section that addresses message queues in the lab manual.
2. Read the manual pages of the following systems calls:
#include
#include
#include
int msgget(key_t key, int msgflg);
int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
Experiment
1. Write two programs and name them send.c and receive.c to send and receive messages from a message queue
respectively. The send program is executed as follows:
./send key type data
it writes the text message data into the message queue whose key is key, where type is the type of the
written message. The receive function, on the other hand, is executed as follows:
./receive key type
it reads a message of type type from the message queue whose key is key if such message exists, and blocks
otherwise. Test your code and show your work to your lab instructor.
Use the following message format:
struct Message{
long type;
char data[15];
}
2. Assume you have two processes, a parent and a child. The parent prints the numbers from 1 to 5, while the
child prints the characters from A to E. Use a single message queue to synchronize the two processes such that
they produce the following output:
1
A
2
B
....
5
E

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

In Problems 7 22 , solve each inequality. x 2 3x 10 < 0

Answered: 1 week ago

Question

What is operatiing system?

Answered: 1 week ago