创建进程函数
参考博客:https://www.cnblogs.com/xudong-bupt/archive/2013/03/26/2982029.htm
互斥变量:pthread_mutex_t
参考博客:https://blog.csdn.net/guotianqing/article/details/80559865
对互斥量加锁解锁的函数
#include <pthread.h>
int pthread_mutex_tlock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthreadd_mutex_t *mutex);
sem_t
参考博客:https://blog.csdn.net/Dancer__Sky/article/details/71101808
sem_wait():使线程阻塞等待
sem_post():解除A线程阻塞
volatile
volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。