Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- *
- * CS 441/541: Bounded Buffer (Project 4)
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <unistd.h>
- #include <errno.h>
- #include <pthread.h>
- #include "semaphore_support.h"
- /*****************************
- * Defines
- *****************************/
- #define TRUE 1
- #define FALSE 0
- /*****************************
- * Structures
- *****************************/
- /*****************************
- * Global Variables
- *****************************/
- int buffer_size = 10;
- int *buffer;
- int elements_produced;
- int elements_consumed;
- int sleep_time;
- int num_producer_threads;
- int num_consumer_threads;
- int in;
- int out;
- semaphore_t mutex;
- semaphore_t full;
- semaphore_t empty;
- /*****************************
- * Function Declarations
- *****************************/
- int insert_item(int item);
- int remove_item();
- void *producer(void *threadid);
- void *consumer(void *threadid);
- void print_inital_info();
- void print_buffer(int thread_type, int thread_id, int item_entered);
- int init_buffer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement