Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. 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

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions