Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help with Coding in C--please Deliverables 1. Submit to Websourses the developed concurrency.cm source code file Assignment requirements 1. Two producers 2. Two consumers

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedNeed Help with Coding in C--please

Deliverables 1. Submit to Websourses the developed concurrency.cm source code file Assignment requirements 1. Two producers 2. Two consumers 3. Mutual exclusion 4. Single buffer with maximum size 10 elements 5. Maximum 30 items produced and consumed for each producer-consumer pair Tasks Activity concurrency.em 1. Create a new CM source code file named concurrency.cm 2. Declare the following global variables a. Data type semaphore named full b. Data type semaphore named empty c. Data type semaphore named mutex d. Constant integer, value 10, for the maximum size of the buffer that stores the produced items e. Integer array with the size as defined in step d. f. Constant integer, value 30, for the maximum number of produced items for each producer 3. Write function producer to do the following a. Return type void b. Parameter list receives one integer designating the producer number (i.e. producer 1, producer 2) c. Loop while the producer has not produced the maximum of 30 items i. Apply exclusive lock on semaphores (i.c. wait or p) ii. Produce the item iii. Add item to buffer iv. Output to screen the produced item v. Calculate the next position in the buffer for the next item vi. Unlock semaphores (i.e. signal or v) d. Output the total number of items produced using mutual exclusion so the output cannot be interleaved 4. Write function consumer to do the following a. Return type void b. Parameter list receives one integer designating the producer number (1.e. consumer 1, consumer 2) c. Loop while the consumer has not consumed the maximum of 30 items i. Apply exclusive lock on semaphores (i.e. wait or p) ii. Consume an item from the buffer iii. Output to screen the consumed item iv. Calculate the next position in the buffer for the next item v. Unlock semaphores (i.e. signal or v) d. Output the total number of items consumed using mutual exclusion so the output cannot be interleaved 5. Write function statement to do the following a. Output the following information i. Student name ii. Course CGS3763 iii. University UCF 6. Write function main to do the following a. Declare four integers that will represent the two producers and two consumers b. Call function initialsem to initialize each of the three semaphores i. full with integer 10; use constant versus hardcode values ii. mutex with integer of 1; this value indicates a binary semaphore iii. empty with integer of c. Call function statement d. Write the cobegin block to concurrently call AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 AL T. 1. AaBb Cet AaBbCcDdE AaBbCcDdE ~ A Aa AO x ALA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates * Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Test Case 1 Producer 1 should produce 30 items Test Case 2 Producer 2 should produce 30 items Test Case 3 Consumer 1 should consume 30 items Test Case 4 Cosnumer 2 should consume 30 items Test Case 5 Output should be similar to example provided Concurrency.cm Example Output Source code written by Karin Whiting CGS 3763 UCF Producer 1 produced item 1 Consumer 1 consumed item 1 from the buffer Producer 2 produced item 1 Consumer 2 consumed item 1 from the buffer Producer 2 produced item 2 Producer 1 produced item 2 Producer 2 produced item 3 Consumer 1 consumed item 2 from the buffer Consumer 2 consumed item 2 from the buffer Consumer 1 consumed item 3 from the buffer Producer 1 produced item 3 Consumer 1 consumed item 4 from the buffer Producer 1 produced item 4 Consumer 1 consumed item 5 from the buffer Producer 1 produced item 5 Producer 2 produced item 4 Consumer 1 consumed item 6 from the buffer Consumer 2 consumed item 3 from the buffer Producer 1 produced item 6 Producer 2 produced item 5 Consumer 2 consumed item 4 from the buffer Producer 1 produced item 7 Producer 2 produced item 6 Producer 1 produced item 8 Consumer 1 consumed item 7 from the buffer Producer 1 produced item 9 Consumer 2 consumed item 5 from the buffer Producer 1 produced item 10 Producer 2 produced item 7 Producer 1 produced item 11 Consumer 1 consumed item 8 from the buffer Producer 2 produced item 8 Producer 1 produced item 12 Consumer 2 consumed item 6 from the buffer Page 3 of 6 1315 words English (United States) Focus + 93% AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21 T. 1. AaBb Cel AaBbCcDdE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Consumer 1 consumed item 9 from the buffer Consumer 2 consumed item 7 from the buffer Consumer 1 consumed item 10 from the buffer Producer 1 produced item 13 Producer produced item 9 Producer 1 produced item 14 Consumer 1 consumed item 11 from the buffer Producer 2 produced item 10 Consumer 2 consumed item 8 from the buffer Producer 1 produced item 15 Consumer 1 consumed item 12 from the buffer Consumer 2 consumed item 9 from the buffer Producer 1 produced item 16 Consumer 2 consumed item 10 from the buffer Producer 2 produced item 11 Producer 1 produced item 17 Consumer 1 consumed item 13 from the buffer Producer 2 produced item 12 Producer 1 produced item 18 Consumer 2 consumed item 11 from the buffer Consumer 1 consumed item 14 from the buffer Producer 2 produced item 13 Consumer 1 consumed item 15 from the buffer Producer 1 produced item 19 Consumer 1 consumed item 16 from the buffer Producer 2 produced item 14 Consumer 2 consumed item 12 from the buffer Producer 1 produced item 20 Consumer 1 consumed item 17 from the buffer Producer 2 produced item 15 Consumer 2 consumed item 13 from the buffer Producer 1 produced item 21 Consumer 1 consumed item 18 from the buffer Producer 2 produced item 16 Consumer 2 consumed item 14 from the buffer Producer 1 produced item 22 Consumer 1 consumed item 19 from the buffer Producer 2 produced item 17 Consumer 1 consumed item 20 from the buffer Producer 1 produced item 23 Producer 2 produced item 18 Consumer 1 consumed item 21 from the buffer Consumer 2 consumed item 15 from the buffer Consumer 1 consumed item 22 from the buffer Producer 1 produced item 24 Consumer 2 consumed item 16 from the buffer Page 3 of 6 1315 words English (United States) Focus + 95% AutoSave OFF WCGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21. T. 1. AaBbCet AaBbCcDE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Consumer 1 consumed item 23 from the buffer Consumer 2 consumed item 17 from the buffer Producer 1 produced item 25 Consumer 2 consumed item 18 from the buffer Producer 2 produced item 19 Producer 1 produced item 26 Consumer 1 consumed item 24 from the buffer Consumer 2 consumed item 19 from the buffer Consumer 1 consumed item 25 from the buffer Consumer 2 consumed item 20 from the buffer Consumer 1 consumed item 26 from the buffer Consumer 2 consumed item 21 from the buffer Producer 1 produced item 27 Consumer 1 consumed item 27 from the buffer Producer 2 produced item 20 Producer 1 produced item 28 Consumer 1 consumed item 28 from the buffer Consumer 2 consumed item 22 from the buffer Producer 2 produced item 21 Producer 1 produced item 29 Consumer 1 consumed item 29 from the buffer Consumer 2 consumed item 23 from the buffer Producer 1 produced item 30 Consumer 1 consumed item 30 from the buffer Producer 2 produced item 22 Producer 1 produced 30 items Consumer 2 consumed item 24 from the buffer Producer 2 produced item 23 Consumer 1 consumed 30 items Consumer 2 consumed item 25 from the buffer Producer 2 produced item 24 Producer 2 produced item 25 Consumer 2 consumed item 26 from the buffer Producer 2 produced item 26 Consumer 2 consumed item 27 from the buffer Producer 2 produced item 27 Producer 2 produced item 28 Consumer 2 consumed item 28 from the buffer Producer 2 produced item 29 Consumer 2 consumed item 29 from the buffer Producer 2 produced item 30 FEED Page 3 of 6 1315 words English (United States) Focus 95% AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21. 1. AaBbCet AaBbCcDE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Check for Updates 6 Producer 2 produced 30 items Consumer 2 consumed item 30 from the buffer Consumer 2 consumed 30 items Page 3 of 6 1315 words English (United States) Focus 95% Deliverables 1. Submit to Websourses the developed concurrency.cm source code file Assignment requirements 1. Two producers 2. Two consumers 3. Mutual exclusion 4. Single buffer with maximum size 10 elements 5. Maximum 30 items produced and consumed for each producer-consumer pair Tasks Activity concurrency.em 1. Create a new CM source code file named concurrency.cm 2. Declare the following global variables a. Data type semaphore named full b. Data type semaphore named empty c. Data type semaphore named mutex d. Constant integer, value 10, for the maximum size of the buffer that stores the produced items e. Integer array with the size as defined in step d. f. Constant integer, value 30, for the maximum number of produced items for each producer 3. Write function producer to do the following a. Return type void b. Parameter list receives one integer designating the producer number (i.e. producer 1, producer 2) c. Loop while the producer has not produced the maximum of 30 items i. Apply exclusive lock on semaphores (i.c. wait or p) ii. Produce the item iii. Add item to buffer iv. Output to screen the produced item v. Calculate the next position in the buffer for the next item vi. Unlock semaphores (i.e. signal or v) d. Output the total number of items produced using mutual exclusion so the output cannot be interleaved 4. Write function consumer to do the following a. Return type void b. Parameter list receives one integer designating the producer number (1.e. consumer 1, consumer 2) c. Loop while the consumer has not consumed the maximum of 30 items i. Apply exclusive lock on semaphores (i.e. wait or p) ii. Consume an item from the buffer iii. Output to screen the consumed item iv. Calculate the next position in the buffer for the next item v. Unlock semaphores (i.e. signal or v) d. Output the total number of items consumed using mutual exclusion so the output cannot be interleaved 5. Write function statement to do the following a. Output the following information i. Student name ii. Course CGS3763 iii. University UCF 6. Write function main to do the following a. Declare four integers that will represent the two producers and two consumers b. Call function initialsem to initialize each of the three semaphores i. full with integer 10; use constant versus hardcode values ii. mutex with integer of 1; this value indicates a binary semaphore iii. empty with integer of c. Call function statement d. Write the cobegin block to concurrently call AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 AL T. 1. AaBb Cet AaBbCcDdE AaBbCcDdE ~ A Aa AO x ALA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates * Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Test Case 1 Producer 1 should produce 30 items Test Case 2 Producer 2 should produce 30 items Test Case 3 Consumer 1 should consume 30 items Test Case 4 Cosnumer 2 should consume 30 items Test Case 5 Output should be similar to example provided Concurrency.cm Example Output Source code written by Karin Whiting CGS 3763 UCF Producer 1 produced item 1 Consumer 1 consumed item 1 from the buffer Producer 2 produced item 1 Consumer 2 consumed item 1 from the buffer Producer 2 produced item 2 Producer 1 produced item 2 Producer 2 produced item 3 Consumer 1 consumed item 2 from the buffer Consumer 2 consumed item 2 from the buffer Consumer 1 consumed item 3 from the buffer Producer 1 produced item 3 Consumer 1 consumed item 4 from the buffer Producer 1 produced item 4 Consumer 1 consumed item 5 from the buffer Producer 1 produced item 5 Producer 2 produced item 4 Consumer 1 consumed item 6 from the buffer Consumer 2 consumed item 3 from the buffer Producer 1 produced item 6 Producer 2 produced item 5 Consumer 2 consumed item 4 from the buffer Producer 1 produced item 7 Producer 2 produced item 6 Producer 1 produced item 8 Consumer 1 consumed item 7 from the buffer Producer 1 produced item 9 Consumer 2 consumed item 5 from the buffer Producer 1 produced item 10 Producer 2 produced item 7 Producer 1 produced item 11 Consumer 1 consumed item 8 from the buffer Producer 2 produced item 8 Producer 1 produced item 12 Consumer 2 consumed item 6 from the buffer Page 3 of 6 1315 words English (United States) Focus + 93% AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21 T. 1. AaBb Cel AaBbCcDdE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Consumer 1 consumed item 9 from the buffer Consumer 2 consumed item 7 from the buffer Consumer 1 consumed item 10 from the buffer Producer 1 produced item 13 Producer produced item 9 Producer 1 produced item 14 Consumer 1 consumed item 11 from the buffer Producer 2 produced item 10 Consumer 2 consumed item 8 from the buffer Producer 1 produced item 15 Consumer 1 consumed item 12 from the buffer Consumer 2 consumed item 9 from the buffer Producer 1 produced item 16 Consumer 2 consumed item 10 from the buffer Producer 2 produced item 11 Producer 1 produced item 17 Consumer 1 consumed item 13 from the buffer Producer 2 produced item 12 Producer 1 produced item 18 Consumer 2 consumed item 11 from the buffer Consumer 1 consumed item 14 from the buffer Producer 2 produced item 13 Consumer 1 consumed item 15 from the buffer Producer 1 produced item 19 Consumer 1 consumed item 16 from the buffer Producer 2 produced item 14 Consumer 2 consumed item 12 from the buffer Producer 1 produced item 20 Consumer 1 consumed item 17 from the buffer Producer 2 produced item 15 Consumer 2 consumed item 13 from the buffer Producer 1 produced item 21 Consumer 1 consumed item 18 from the buffer Producer 2 produced item 16 Consumer 2 consumed item 14 from the buffer Producer 1 produced item 22 Consumer 1 consumed item 19 from the buffer Producer 2 produced item 17 Consumer 1 consumed item 20 from the buffer Producer 1 produced item 23 Producer 2 produced item 18 Consumer 1 consumed item 21 from the buffer Consumer 2 consumed item 15 from the buffer Consumer 1 consumed item 22 from the buffer Producer 1 produced item 24 Consumer 2 consumed item 16 from the buffer Page 3 of 6 1315 words English (United States) Focus + 95% AutoSave OFF WCGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21. T. 1. AaBbCet AaBbCcDE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Check for Updates Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Consumer 1 consumed item 23 from the buffer Consumer 2 consumed item 17 from the buffer Producer 1 produced item 25 Consumer 2 consumed item 18 from the buffer Producer 2 produced item 19 Producer 1 produced item 26 Consumer 1 consumed item 24 from the buffer Consumer 2 consumed item 19 from the buffer Consumer 1 consumed item 25 from the buffer Consumer 2 consumed item 20 from the buffer Consumer 1 consumed item 26 from the buffer Consumer 2 consumed item 21 from the buffer Producer 1 produced item 27 Consumer 1 consumed item 27 from the buffer Producer 2 produced item 20 Producer 1 produced item 28 Consumer 1 consumed item 28 from the buffer Consumer 2 consumed item 22 from the buffer Producer 2 produced item 21 Producer 1 produced item 29 Consumer 1 consumed item 29 from the buffer Consumer 2 consumed item 23 from the buffer Producer 1 produced item 30 Consumer 1 consumed item 30 from the buffer Producer 2 produced item 22 Producer 1 produced 30 items Consumer 2 consumed item 24 from the buffer Producer 2 produced item 23 Consumer 1 consumed 30 items Consumer 2 consumed item 25 from the buffer Producer 2 produced item 24 Producer 2 produced item 25 Consumer 2 consumed item 26 from the buffer Producer 2 produced item 26 Consumer 2 consumed item 27 from the buffer Producer 2 produced item 27 Producer 2 produced item 28 Consumer 2 consumed item 28 from the buffer Producer 2 produced item 29 Consumer 2 consumed item 29 from the buffer Producer 2 produced item 30 FEED Page 3 of 6 1315 words English (United States) Focus 95% AutoSave OFF W CGS3763_Assignment4 2 - Saved to my Mac Home Insert Draw Design Layout References Mailings Review View Developer Share Comments Co- Times New... 14 21. 1. AaBbCet AaBbCcDE AaBbCcDdE ~ A Aa AO x APA AaBbCcDd Heading 1 Paste B I U v ab x Heading 2 Normal No Spacing Styles Pane Dictate Sensitivity Office Update To keep up-to-date with security updates, fixes, and improvements, choose Check for Updates. Check for Updates 6 Producer 2 produced 30 items Consumer 2 consumed item 30 from the buffer Consumer 2 consumed 30 items Page 3 of 6 1315 words English (United States) Focus 95%

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

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago