Question
. Consider the following structure definition. struct student { int id; char name[64]; char lastname[64]; int age; double cgpa; }; Write a producer program and
. Consider the following structure definition.
struct student {
int id;
char name[64];
char lastname[64];
int age;
double cgpa;
};
Write a producer program and a consumer program. You will use shared memory to pass student information from the producer to the consumer for 3 students. You can set the values for the students to anything you like. You will use POSIX shared memory API. Learn more about it by typing man shm_overview at Linux command line.
Note that if shmptr is a variable pointing to some location in the shared memory, then you can put (write) student information into that location as below. You can use a similar approach for getting (reading) the information.
struct student *sp;
sp = (struct student *) shmptr;
sp->id = 1045;
strcpy (sp->name, Ali);
.
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