A group of 10 students are meeting to study CS222 midterm exam, the first six students who arrived first will order cakes (each student will order one cake at a time), and the late students i.e., the remaining four students will eat the cakes delivered by those students where each one of those four students is allowed to eat one cake only. Write a C-code that synchronizes the ordering and eating processes.   Keep in mind the following requests: Initiate counters to keep track of the eating and ordering processes and display proper printing statements to follow these operations. Use only counting or binary semaphores (Don’t use Mutex at all) Generate threads array to represent the students.   Hint: don’t you think this problem is similar to the producer-consumer problem!   Don’t forget to support your code with proper comments (i.e., documentation)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.3: Nested If Statements
Problem 7E
icon
Related questions
Topic Video
Question

A group of 10 students are meeting to study CS222 midterm exam, the first six students who arrived first will order cakes (each student will order one cake at a time), and the late students i.e., the remaining four students will eat the cakes delivered by those students where each one of those four students is allowed to eat one cake only. Write a C-code that synchronizes the ordering and eating processes.

 

Keep in mind the following requests:

  1. Initiate counters to keep track of the eating and ordering processes and display proper printing statements to follow these operations.
  2. Use only counting or binary semaphores (Don’t use Mutex at all)
  3. Generate threads array to represent the students.

 

Hint: don’t you think this problem is similar to the producer-consumer problem!

 

Don’t forget to support your code with proper comments (i.e., documentation)

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr