Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /*
  2. *
  3. *
  4. * CS 441/541: Bounded Buffer (Project 4)
  5. *
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <time.h>
  10. #include <unistd.h>
  11. #include <errno.h>
  12. #include <pthread.h>
  13. #include "semaphore_support.h"
  14.  
  15. /*****************************
  16. * Defines
  17. *****************************/
  18. #define TRUE 1
  19. #define FALSE 0
  20.  
  21. /*****************************
  22. * Structures
  23. *****************************/
  24.  
  25.  
  26. /*****************************
  27. * Global Variables
  28. *****************************/
  29. int buffer_size = 10;
  30. int *buffer;
  31.  
  32. int elements_produced;
  33. int elements_consumed;
  34. int sleep_time;
  35. int num_producer_threads;
  36. int num_consumer_threads;
  37. int in;
  38. int out;
  39.  
  40. semaphore_t mutex;
  41. semaphore_t full;
  42. semaphore_t empty;
  43. /*****************************
  44. * Function Declarations
  45. *****************************/
  46. int insert_item(int item);
  47. int remove_item();
  48. void *producer(void *threadid);
  49. void *consumer(void *threadid);
  50. void print_inital_info();
  51. void print_buffer(int thread_type, int thread_id, int item_entered);
  52. int init_buffer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement