//声明
sem_t sem;
//chushihua初始化
sem_init(&sem,0,0);
//xinhaoliang信号量-
sem_wait(&sem);
//xinhaoliang信号量+
sem_post(&sem);
sem_destroy(&sem );
sem_destroy(&sem );
//信号量销毁
【头文件】
#include <semaphore.h>
【函数】
int sem_init(sem_t *sem, int pshared, unsigned int value);
@
/*互斥锁*/
pthread_mutex_t lock; //声明
pthread_mutex_init (&lock, NULL); //初始化
pthread_mutex_lock (&lock); //上锁
pthread_mutex_unlock (&lock); //解锁
pthread_mutex_destroy(&lock); //删除互斥锁