CS492 Programming Assignment-
The program must be written in C or C++, and run on a linux machine.
ALL source code you submit must be well documented (documentation is an indicator of understanding!)
Programs that cannot be compiled by TA/CA will receive an automatic grade of zero (0).
The goal of this assignment is to simulate a producer-consumer system using threads, mutexes, condition variables and scheduling. You will experiment with varying the numbers of available producer and consumer threads, the number of products, and the scheduling algorithm used to schedule the consumption of products. Your program must accept the following parameters at the command prompt in the order specified:
- P1: Number of producer threads
- P2: Number of consumer threads
- P3: Total number of products to be generated by all producer threads
- P4: Size of the queue to store products for both producer and consumer threads (0 for unlimited queue size)
- P5: 0 or 1 for type of scheduling algorithm: 0 for First-Come-First-Serve, and 1 for Round-Robin
- P6: Value of quantum used for round-robin scheduling
- P7: Seed for random number generator
The scheduling algorithms your program must simulate are:
- 0: First Come, First Serve
- 1: Round-Robin
Man pages that you may need to consult are:
- man pthread
- man 3 random
- man 3 srandom
- man 3 drand48
- man 3 srand48
- man 2 gettimeofday
- man 3 clock
Attachment:- Programming Assignment.rar