Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project you need to apply message queue concepts to allow two processes to send message between each other. The code included to this

In this project you need to apply message queue concepts to allow two processes to send message between each other. The code included to this project is doing the message queue code for two processes. You need to allow the sender to send message and enter waiting as soon as it did not receive acknowledgment from the receiver, and he will send again a new message as he receive acknowledgment. Note: you need to allow both processes to be sender and receiver at the same time by initiating two message queues for sending and receiving.

Note: use the following Flow-chart to understand the issue

image text in transcribed

Note: please import the code into you device and run it.

See the example of running both sender and receiver

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Start WHILE INPUT :- * Sender Receiver Send Fest Message ONLY Acknowlegment Message Queue YES Acknowledge It Message Queur SNED Message 1 IfAKNOW -NO WAIT instructor advancedprogramming: -/Documents/advanced programming/ShA-X instructor advancedprogramming: Documents/advanced programming/Sh - X File Edit View Search Terminal Help File Edit View Search Terminal Help instructor advancedprogramming:-/Documents/advanced_programming/Shared Memory$/instructor advancedprogramming:-/Documents/advanced programming/Shared Memorys/ sender receiver Enter a message:myname is mahmoud myname is mahmoud Message sentinstructor advancedprogramming:-/Documents/advanced_programing/Shar instructor advancedprogramming:-/Documents/advanced_programming/SharedMenorys edMemory Sender code: #include #include #include #include #include #include #define MAXSIZE 128 /* To send a message, there should be a message buffer. The Clibrary has provided a default template structure "msgbuf" that is present in "sys/msg.h" *7 typedef struct long mtype; char mtext[MAXSIZE] }msgbuf; int main(void) // key_t key:// ftok-convert a pathname and a project identifier to a System V IPC key //key=ftok("file.txt", "b"); 1/printf("Key %d", key); int msgid; key_t key=123456; int msgflag-IPC_CREAT0666; msgbuf buf; size_t buflen; iff(msgid=msgget(key,msgflag]} #include #include #include #include #include #define MAXSIZE 128 1 To send a message, there should be a message buffer. The C library has provided a default template structure "msgbuf" that is present in sys/msg." *7 typedef struct long mtype; char mtext[MAXSIZE); msgbuf; int main(void) //key_t key:// ftok-convert a pathname and a project identifier to a System V IPC key // key=ftok("file.txt", "b"); // printf("Key%d", key); int msgid; key_t key=123456; int msgflag=IPC_CREAT0666; msgbuf buf; iff(msgid=msgget(key,0666))(O) perror("message queue error"); if(msgrev/msgid,&buf, MAXSIZE,1,0)(0) { perror("Cant receive message"); }else{ printf("%s ", buf.mtext); 1 return 0; }

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

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions