Question: (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)?????
THAT IS THE CODE CHANGE OR ADD WHAT IS IT REQUIRED
THE FULL QUESTION AND INFORMATION INSIDE THE PHOTOS PLEASE OPEN IT
the code in c language
Sender code:
#include
#include
#include
#include
#include
#include
#define MAXSIZE 128
/*
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.h
*/
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 msqid;
key_t key=123456;
int msgflag=IPC_CREAT | 0666;
msgbuf buf;
size_t buflen;
if((msqid=msgget(key,msgflag))
perror("Message error");
//message type
buf.mtype=1;
printf("Enter a message:");
scanf("%[^ ]",buf.mtext);
getchar();
buflen=strlen(buf.mtext)+1;
if(msgsnd(msqid,&buf,buflen,IPC_NOWAIT)
printf("Error while sending a message");
}else{
printf("Message sent");
}
return 0;
}
Receiver Code
#include
#include
#include
#include
#include
#include
#define MAXSIZE 128
/*
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.h
*/
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 msqid;
key_t key=123456;
int msgflag=IPC_CREAT | 0666;
msgbuf buf;
if((msqid=msgget(key,0666))
perror("message queue error");
if(msgrcv(msqid,&buf,MAXSIZE,1,0)
{
perror("Cant receive message");
}else{
printf("%s ",buf.mtext);
}
return 0;
}


Start WHILE INPUT I= X Sender Receiver Send First Message ONLY Lacknowlement Message QUELE -YES Acknowledge A Message Queue SNED Message > 1 If AKNOW -NO WAIT IPC 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: lease use the following Flow-chart to understand the issue. Note: please import the code into you device and run it. See the example of running both sender and receiver instructor advancedprogramming - Documentadvanced programming ish trucursdvancedprogramming Documentsadvanced programmings Filedit View Search Terminal Help Search Termal Lastructor advancedprograming-/Documents/advanced programming/Shared enorys sender Instructor advanced programming:-/Decuments/advanced programming/Sharedfesor corys/ Enter a message myname is nanoud olver ne is Message sent instructor advanced programming/Documents/advanced programming/Sharinstructor advanced programming/curs/advanced programming/Sharedtesorys ( marys
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
