Question: In this project, you will complete a multi - threaded synchronization problem using semaphores and mutexes in a partially completed project code. The problem involves
In this project, you will complete a multithreaded synchronization problem using semaphores and
mutexes in a partially completed project code. The problem involves multiple levels of producers
and consumers interacting with two bounded buffers. The primary goal is to understand and
demonstrate synchronization mechanisms to ensure safe and efficient access to shared resources
in a concurrent environment.
Project Description
You will require two types of buffer to implement this project. The first buffer Buffer where
initial producer threads producer and place their items Intermediate consumerproducer
threads consume items from Buffer and place their processed items in second buffer Buffer
Threads: You need to create three types of threads:
o Producers: These threads will produce items and place them into Buffer Ensure that
producers wait if Buffer is full, using semaphores and mutexes for synchronization.
o First Level ConsumersProducers: These threads will consume items from Buffer
process them, and then produce new items into Buffer Ensure that these threads wait
if Buffer is empty or if Buffer is full, using semaphores and mutexes for
synchronization.
o Second Level Consumers: These threads will consume items from Buffer Ensure
that they wait if Buffer is empty, using semaphores and mutexes for synchronization.
Synchronization: To handle the synchronization between threads, you must use semaphores
and mutexes. Semaphores will be used to manage the full and empty states of each buffer,
while mutexes will ensure mutual exclusion when accessing the shared buffers. This
combination will help to avoid race conditions and ensure that the buffers are accessed safely
and efficiently by multiple threads.
Additional Requirements
Your program should gracefully terminate after items have been produced, processed, and
consumed. This number will be defined by a constant. Each thread should complete its assigned
tasks and then terminate, ensuring that all items are handled correctly before the program ends.
Partial Code
The code is provided with all the required function on Canvas assignment page. You need to
complete the code in the main section to demonstrate the output with synchronization
requirements. There are functions for produce and consume for producing and consuming items.
CSC OPERATING SYSTEM PRINCIPLES SUMMER
Furthermore, there functions for producer entity firstlevelconsumerproducer entity and
secondlevelconsumer entity. You need to fill out the main section of the code.
Group Formation
You must create a group of minimum and maximum members to complete the project work.
You can sign up for the groups on Canvas in the people section under Project GRP You
should communicate with your group members to work together on this project through Canvas
messages, Emails or other available messaging applications like Discord. The final day to complete
group formation is th July. The group members can take up the roles as project lead, document
creatoreditor technical expertcode etc.
Output Requirements
The output of the program should display the sequence of produced and consumed items,
indicating which buffer they were placed into or taken from. The project considers that there are
two producer entities to produce items and place them in Buffer two producerconsumer entities
who consume from Buffer and produce items in buffer and lastly, there are consumer entities
who consume items from buffer Each operation should be printed to the console with clear
identification of the thread performing the action and the buffer involved. For example:
base SacStar:SMR Syed$ producerconsumerproject
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
Producer ID: Produced: into Buffer
Producer ID: Produced: into Buffer
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
ConsumerID: Consumed: from Buffer
ConsumerID: Consumed: from Buffer
ConsumerID: Consumed: from Buffer
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
ConsumerID: Consumed: from Buffer
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
Producer ID: Produced: into Buffer
Producer ID: Produced: into Buffer
ConsumerID: Consumed: from Buffer
Producer ID: Produced: into Buffer
ConsumerID: Consumed: from Buffer
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
Consumer ID: Consumed: from Buffer
Producer ID: Produced: into Buffer
ConsumerID: Consumed: from Buffer
Producer ID: Produced: into Buffer
Consumer ID: Consumed: from Buffer
CSC OPERATING SYSTEM PRINCIPLES SUMMER
Producer ID: Produced: into Buffer
Producer ID: Produced:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
