Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

undefined Q1 (Shared memory) (20 points) The following programs are non-completed Producer and Consumer programs such that: A shared memory with size 5 was created

image text in transcribedundefined

Q1 (Shared memory) (20 points) The following programs are non-completed Producer and Consumer programs such that: A shared memory with size 5 was created by the producer. You should complete these programs such that: The producer fills the shared memory with the integers: -1, 2, -3,4,5. The consumer will convert all negative numbers to positive numbers (i.e.,the integers in the shared memory will be 1,2,3,4,5). Then, the consumer terminates. If the producer finds that the first integer in the memory is a positive integer then it will add 3 to all integers (i.e., the integers in the shared memory will be 4, 5, 6, 7, 8) then the producer terminates. Producer.c Consumer.c #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHMSZ5 #define SHMSZ 5 int main(){ int main(){ int shmid;key_t key;int *shm;key=5678; int shmid;key_tkey:int *shm;key=5678; if((shmid=shmget(key,SHMSZ, IPC_CREAT0666))>0){ if((shmid=shmget(key, SHMSZ, IPC_CREAT0666)) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SHMSZ5 #define SHMSZ 5 int main(){ int main(){ int shmid;key_t key;int *shm;key=5678; int shmid;key_tkey:int *shm;key=5678; if((shmid=shmget(key,SHMSZ, IPC_CREAT0666))>0){ if((shmid=shmget(key, SHMSZ, IPC_CREAT0666))

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions