+ int opt;
+ while ((opt = getopt(argc, argv, "c:C:p:P:q")) != -1) {
+ switch (opt) {
+ case 'q':
+ do_output = 0;
+ break;
+ case 'c':
+ AmountConsumed = atoi(optarg);
+ break;
+ case 'C':
+ ConsumerCount = atoi(optarg);
+ break;
+ case 'p':
+ AmountProduced = atoi(optarg);
+ break;
+ case 'P':
+ ProducerCount = atoi(optarg);
+ break;
+ default: /* '?' */
+ printf("unknown option: %c\n", optopt);
+ break;
+ }
+ }
+ pthread_t* pro = malloc(ProducerCount * sizeof(pthread_t));
+ pthread_t* con = malloc(ConsumerCount * sizeof(pthread_t));
+ buffer = malloc(sizeof(int) * BufferSize);