Advanced Operating Systems (CS 5500)

Advanced Operating Systems (CS 5500)

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on  +1(629)-237-5579

You are allowed to discuss the problem and solution design with others, but the code you submit
must be your own. Your solution must include the certification of authenticity “I certify that the
code in the method functions including method function main of this project are entirely my own
work.”
Process Synchronization using Monitor
The purpose of this programming project is to explore process synchronization. This will be
accomplished by writing a program to solve the bounded buffer problem using monitor concept.
Your program must be written using C or C++ and you are required to use the Pthread libraries.
Bounded buffer is used to enable multiple producers and consumers processes to share memory. Essaycove.com
A producer can place items into the buffer only if the buffer has a free memory location to store
the item. A producer cannot add items to a full buffer. A consumer can remove items from the
buffer if the buffer is not empty. A consumer must wait to consume items if the buffer is empty.
The “items” stored in this buffer will be integers. Your producer processes will have to insert
random numbers into the buffer. The consumer processes will consume a number.
Assignment Specifications
The buffer used between producer and consumer processes will consist of a fixed-size array of
type buffer_item. The queue of buffer_item objects will be manipulated using a circular array.
The producer thread will alternate between sleeping for a random period of time and generating
and inserting (trying to) an integer into the buffer. Random numbers will be generated using the
rand_r() function.
The consumer thread will alternate between sleeping for a random period of time (thread safe of
course) and (trying to) removing a number out of the buffer.
The main function will initialize the buffer and create the separate producer and consumer
threads. Once it has created the producer and consumer threads, the main() function will sleep
for duration of the simulation. Upon awakening, the main thread will signal other threads to quit
by setting a simulation flag which is a global variable. The main thread will join with the other
threads and then display the simulation statistics. The main() function will be passed two
parameters on the command line:
• The length of time the main thread is to sleep before terminating (simulation length in
seconds)
• The maximum length of time the producer and consumer threads will sleep prior to
producing or consuming a buffer_item
Monitor Solution
You need to use monitor synchronization tool to synchronize multiple producer and consumer
processes. However, Pthread library doesn’t have monitor keyword. Monitor needs to be
implemented using condition variables (pthread_cond_wait(), pthread_cond_timedwait(), and
pthread_cond_signal()) and mutex lock (pthread_mutex_lock(), pthread_mutex_trylock(), and
pthread_mutex_unlock()) of Pthread library.
Program Output
Your simulation should output when various conditions occur: buffer empty/full status, buffer
slots occupied, location of producer/consumer in the buffer, presence or absence of elements in
all the buffer entries
Here is a sample output:
Producer Inserted Item 21 at buffer[0]
buffer slots occupied: 1
buffer_data:
21 -1 -1 -1 -1
Consumer Removed Item 21 from buffer[0]
buffer slots occupied: 0
buffer_data:
-1 -1 -1 -1 -1
buffer is empty
Producer Inserted Item 47 at buffer[1]
buffer slots occupied: 1
buffer_data:
-1 47 -1 -1 -1
Producer Inserted Item 25 at buffer[2]
buffer slots occupied: 2
buffer_data:
-1 47 25 -1 -1
Consumer Removed Item 47 from buffer[1]
buffer slots occupied: 1
buffer_data:
-1 -1 25 -1 -1
Submission Guidelines and Requirements https://charteredessay.com/com1005-machines-and-intelligence/

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

The post Advanced Operating Systems (CS 5500) appeared first on The Writer.