Question
Q.1 : Write a program ( c or c++ ) in which we can implement the concept of Interprocess Communicaton ( IPC ) in between
Q.1 : Write a program ( c or c++ ) in which we can implement the concept of Interprocess Communicaton ( IPC ) in between two departments of cafeteria management system i.e. Receptionist ( who takes the order from customer ) and Food Making Team ( Who makes the order and parcel the meal ).
You have to implement the Interprocess Communication between Receptionist and Food making Team.
Receptionist act as Writer ( Who sends the customer order to Food Making Team )
Food Making Team act as Reader ( Who Recieves the Order Details from Receptionist and make Food Parcels )
For Help/clue:-
The Code for IPC (Writer and Reader) is as follows :-
MESSAGE QUEUE FOR WRITER PROCESS // C Program for Message Queue (Writer Process) #include #include #include
// structure for message queue struct mesg_buffer { long mesg_type; char mesg_text[100]; } message;
int main() { key_t key; int msgid;
// ftok to generate unique key key = ftok("progfile", 65);
// msgget creates a message queue // and returns identifier msgid = msgget(key, 0666 | IPC_CREAT); message.mesg_type = 1;
printf("Write Data : "); gets(message.mesg_text);
// msgsnd to send message msgsnd(msgid, &message, sizeof(message), 0);
// display the message printf("Data send is : %s ", message.mesg_text);
return 0; }
|
|
MESSAGE QUEUE FOR READER PROCESS
// C Program for Message Queue (Reader Process) #include #include #include
// structure for message queue struct mesg_buffer { long mesg_type; char mesg_text[100]; } message;
int main() { key_t key; int msgid;
// ftok to generate unique key key = ftok("progfile", 65);
// msgget creates a message queue // and returns identifier msgid = msgget(key, 0666 | IPC_CREAT);
// msgrcv to receive message msgrcv(msgid, &message, sizeof(message), 1, 0);
// display the message printf("Data Received is : %s ", message.mesg_text);
// to destroy the message queue msgctl(msgid, IPC_RMID, NULL);
return 0; } |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started