C program utilizing multi-threads, mutex lock, and semaphores for the producer and consumer problem.
Define an integer buffer with the size of 32 and implement a circular queue data structure that is used by producers and a consumer. Next, you will need to initialize the mutex lock and semaphores. Here, you will use two semaphores where one indicates a full queue and the other indicates an empty queue. The producer function is used to insert a random number between 0 and 10 to the queue. The consumer function is used to remove a number from the queue in a FIFO fashion. In addition, inside the loops of the producer and consumer functions, add a random delay between 0 and 2 seconds to simulate various lengths of processes. In addition, you are required to use 2 producers and 1 consumer for this project where 0 and 2 are producers and 1 is consumer (3 threads). Finally, code should run forever. where the number is the thread identifier, the second number is the random number inserted to or removed from the queue, and the third number is the queue index. Also, print out a message when the buffer is full or empty.
Code should run in UNIX server.
Expected results should be similar to one in file provided.
5 freelancers are bidding on average $52 for this job
HI..I am proficient in C/C++ programming with multiple POSIX threads along with synchronisation using mutex locks, semaphores and can help you write the producer and consumer program.
Hi... I have already completed projects upon semaphore and mutex locks hence confident enough to complete your project within 2 working days time. Ping me to discuss further