Question: Write a complete program to do the following (Inter-process communication using shared memory). Submit the program on linux. a. Write a typedef statement that defines

Write a complete program to do the following (Inter-process communication using shared memory). Submit the program on linux.

a.Write a typedef statement that defines a structure type with

i.an array, named data, of 30 integer type of elements

ii.two integer type of fields named s and m

b. create a shared memory object and configure the size of a shared memory object with the size of the type defined in a.

c.Declare a variable to store the pointer returned by mmap() function call, and call mmap() to map the shared memory object created in b to process logical space.

d.Write c statements to initialize the field s to 30 and field m to12 in the shared memory object mapped in c.

e.Write c-statements to create exactly two new processes.

i.The first child process stores its process id in

data[0], data[1], , data[m 1]

of the array field data in the shared memory object.

ii.The second child stores its process id in

data[m], data[m+1], , data[s 1]

of the array field data in the shared memory object.

iii.The parent process will wait for both child processes to complete.

The system call getpid() returns the callers process id.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!