Show Bid Request
Producer/Consumer
Bid Request Id: 7480
|
|
|
Description:
Program in ANSI C in UNIX Producer/Consumer contains two types of processes. The first type, producers, create items and add them to a buffer that is shared among all processes. The second type, consumers, extract items from the shared buffer and do consume the extracted item. The buffer contains a finite number of slots to hold produced but not yet consumed items. If the buffer is full, no producer is allowed to add items to the buffer. If buffer is empty, no consumer is allowed to remove an item. 8 producers 12 consumers buffer size of 5 Each producer and consumer will be a separate thread, created by the main() The buffer will be shared, globally declared queue implemented with a circular array of length 6, and will have 2 functions to modify it: enqueue() and dequeue(). Elements in the queue are ints. The signatures for these functions are: void enqueue( int item ); int dequeue();
Access to the buffer variables(array, indices,etc.) is sequentialized with a mutual exclusion semaphore, mutex. You will also have 2 other semaphores named empty and full. The semaphores needed are: mutex-initially set to 1, binary semaphore that is used to control access to the shared buffer. empty-initially set to 5, counting seamphore that controls the number of producers that can concurrently add items to the shared buffer. It is decremented when a producer adds an item and incremented when a consumer extracts an item. full-initially set to 0 counting semaphore controls the number of consumers that can remove items from the shared buffer. It is incremented after a producer adds an item and is decremented when a consumer extracts an item. The following algorithms are to be used for the producer/consumer threads: Producer:: Repeat 12 times Randomly generate an int /*Produce an item*/ Print the generated integer wait on empty /*wait if no empty slots*/ enqueue the int in buffer /* mutex needed*/ post on full /* allow other consumer*/
Consumer:: Repeat 8 times wait on full /* wait if no items ready*/ dequeue the int from buffer/*mutex needed*/ post on empty /*allow another producer*/ /*show that it is consumed*/ Print the integer number
supposed to be an introduction program. Values can be hard-coded.
Deliverables: code e-mailed to me
Special Conditions / Other:
The time deadline is Central Time Zone 9:00pm 1/14/02
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation please help out the site and report it. Thanks for your help.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
|
This bid was accepted by the buyer!
|
$30 (USD)
|
Jan 13, 2002 12:56:57 PM EDT
|
10
(Excellent)
|
|
|
Hello Sir. I have studied this producer-consumer problem completely. I know semaphores and have worked extensively in C/C++, so the code would be delivered on time and as per all requirements, with proper comments. Please close the bid at the earliest to allow sufficient time to code. Regards. Sumegha. |
|
|
|
|
|