*生产者写入数据*/Р if ((real_write = write(fd, "hello", UNIT_SIZE)) == -1)Р {Р if(errno == EAGAIN)Р {Р printf("The FIFO has not been read yet.Please try later\n");Р }Р }Р elseР {Р printf("Write %d to the FIFO\n", real_write);Р }Р Р /*V操作信号量full和mutex*/Р sem_post(&full);Р sem_post(&mutex); Р?}Р?Р?pthread_exit(NULL);Р}Рvoid *customer(void *arg)Р{Р?unsigned char read_buffer[UNIT_SIZE];Р?int real_read;Р?int delay_time;?Р?Р?while(time(NULL) < end_time)Р?{Р delay_time = (int)(rand() * DELAY_TIME_LEVELS/(RAND_MAX)) + 1;Р sleep(delay_time);Р Р /*P操作信号量full和mutex*/Р sem_wait(&full);Р sem_wait(&mutex);Р Р memset(read_buffer, 0, UNIT_SIZE);Р printf("\nCustomer: delay = %d\n", delay_time);Р Р if ((real_read = read(fd, read_buffer, UNIT_SIZE)) == -1)Р {Р if (errno == EAGAIN)Р {Р printf("No data yet\n");Р }Р }