随笔分类 -  Linux C-线程相关函数

摘要:sem_tsem_initsem_waitsem_trywaitsem_timedwaitsem_postsem_destroy 生产者消费者实例: 阅读全文
posted @ 2018-01-11 15:30 夜行过客 阅读(4999) 评论(0) 推荐(0) 编辑
摘要:pthread_cond_tpthread_cond_initpthread_cond_destroypthread_cond_waitpthread_cond_timedwaitpthread_cond_signalpthread_cond_broadcast 生产者消费者模型: 运行结果: Pr 阅读全文
posted @ 2018-01-11 15:06 夜行过客 阅读(492) 评论(0) 推荐(0) 编辑
摘要:读共享,写独占 pthread_rwlock_tpthread_rwlock_initpthread_rwlock_destroypthread_rwlock_rdlockpthread_rwlock_wrlockpthread_rwlock_tryrdlockpthread_rwlock_tryw 阅读全文
posted @ 2018-01-11 14:13 夜行过客 阅读(3188) 评论(0) 推荐(0) 编辑
摘要:互斥锁实例: #include <pthread.h>pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;int pthread_mutex_destroy(pthread_mutex_t *mutex);int pthread_mutex_init( 阅读全文
posted @ 2018-01-11 10:50 夜行过客 阅读(7671) 评论(0) 推荐(0) 编辑
摘要:#include <pthread.h>int pthread_detach(pthread_t tid); pthread_t tid: 分离线程的tid返回值:成功返回0,失败返回错误号。 一般情况下,线程终止后,其终止状态一直保留到其它线程调用pthread_join获取它的状态为止。但是线程 阅读全文
posted @ 2018-01-10 14:35 夜行过客 阅读(2251) 评论(0) 推荐(0) 编辑
摘要:获取调用线程tid #include <pthread.h>pthread_t pthread_self(void); 示例: 运行结果: main thread: pid 4959 tid 9791296 (0x956740)new thread: pid 4959 tid 1480448 (0x 阅读全文
posted @ 2018-01-10 14:05 夜行过客 阅读(10335) 评论(0) 推荐(0) 编辑
摘要:一. pthread_create() #include <pthread.h> int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg) 阅读全文
posted @ 2018-01-10 11:27 夜行过客 阅读(3755) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示