Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solve using pthreads not windows api!!! Problem Hw3.c code file to go finish coding #include buffer.h #include #include #include #include buffer_item buffer[BUFFER_SIZE]; void *producer(void *param);
Solve using pthreads not windows api!!!
Problem Hw3.c code file to go finish coding
#include "buffer.h"
#include
#include
#include
#include
buffer_item buffer[BUFFER_SIZE];
void *producer(void *param);
void *consumer(void *param);
int insert_item(buffer_item item)
{
/* Acquire Empty Semaphore */
/* Acquire mutex lock to protect buffer */
/* Insert item into buffer */
/* Release mutex lock and full semaphore */
return 0;
}
int remove_item(buffer_item *item)
{
/* Acquire Full Semaphore */
/* Acquire mutex lock to protect buffer */
/* remove an object from buffer placing it in item */
/* Release mutex lock and empty semaphore */
return 0;
}
int main(int argc, char *argv[])
{
/* Get command line arguments argv[1],argv[2],argv[3] */
/* Initialize buffer related synchronization tools */
/* Create producer threads based on the command line input */
/* Create consumer threads based on the command line input */
/* Sleep for user specified time based on the command line input */
return 0;
}
void *producer(void *param)
{
/* producer thread that calls insert_item() */
}
void *consumer(void *param)
{
/* consumer thread that calls remove_item() */
}
Buffer.h file
/* buffer.h*/
typedef int buffer_item;
#define BUFFER_SIZE 5
int insert_item(buffer_item item);
int remove_item(buffer_item *item);
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