Question
Activity Directions: In this project students will design, implement, and evaluate a computing-based solution to meet a given set of computing requirements. Students will demonstrate
Activity Directions: In this project students will design, implement, and evaluate a computing-based solution to meet a given set of computing requirements. Students will demonstrate the ability to create and manage processes and threads.They will create two processes, Producer and Consumer, using the C functions below:
void producer() {
int i;
while(1){
i = produce();
put(i);
}
}
void consumer() {
int i;
while(1){
i = get();
consume(i);
}
}
The Producer is simply creating numbers, which are passed to the Consumer in a static buffer. The students task is to implement the put() and get() functions. Each function will use a buffer (implemented as a word). The objective is to ensure that the producer is always ahead of the consumer and the consumer does not have to wait.
A simple implementation of the produce() and consume() functions is:
int theProduct;
int produce(){
return theProduct++;
}
void consume(int i){
printf(%i, i);
}
Note: Do not use semaphores or other synchronization mechanisms. Rely on threads instead (include the pthread.h library). You may use sleep and wakeup commands.
Deliverables:
- An explanation of your approach to implementation and its reasoning
- Program execution results:
Comment header in the code, describing the solution and identifying the programmer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started