【作业】:结合生产者消费者信号量模型,揣摩sem_timedwait函数作用。编程实现,一个线程读用户输入, 另一个线程打印“hello world”。如果用户无输入,则每隔5秒向屏幕打印一个“hello world”;如果用户有输入,立刻打印“HELLO WORLD”到屏幕。
linux下没有getch这个函数
https://blog.csdn.net/ldx19980108/article/details/74853373
解决了输入键盘不需要按回车的问题
#include<stdio.h>
#include<unistd.h>
#include<pthread.h>
#include<semaphore.h>
#include<stdlib.h>
#include<time.h>
char getch()
{
char c;
system("stty -echo"); //不回显
system("stty -icanon");