![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
系统编程
文章平均质量分 59
Qian_F
这个作者很懒,什么都没留下…
展开
-
线程的同步--条件变量
相关函数 pthread_cond_init() pthread_cond_wait() pthread_cond_signal() pthread_cond_broadcast() pthread_cond_distroy() #include #include #include #include #include char buf[40] = {0}; pt原创 2012-11-18 20:52:03 · 837 阅读 · 0 评论 -
线程的同步--互斥锁
相关函数 pthread_mutex_init() pthread_mutex_lock() pthread_mutex_trylock() pthreaad_mutex_unlock() pthread_mutex_destroy() 请看下面一个程序: #include #include #include #include #include char buf[原创 2012-11-18 15:38:16 · 660 阅读 · 0 评论 -
线程的创建与退出
头文件 #include 线程的创建 pthread_create() 线程的退出 pthread_exit() 等待线程的退出 pthread_join() #include #include #include void thread() { printf("This is child thread!\n"); return ;原创 2012-11-17 22:33:53 · 921 阅读 · 0 评论 -
线程的同步--信号量
除了互斥锁以及条件变量,还有信号量可以来进行线程同步。信号量从本质上讲是一个非负证书计数器,通常用来控制对公共资源的访问。 相关函数(头文件 #include ): int sem_init(sem_t *sem, int pshared, unsigned value) int sem_post(sem_t *sem) int sem_wait(sem_t *sem) int sem原创 2012-11-18 23:09:57 · 741 阅读 · 0 评论