2016年9月11日

Linux Linux程序练习九

摘要: 题目:利用多线程与有名管道技术,实现两个进程之间发送即时消息,实现聊天功能 思路:关键在于建立两个有名管道,利用多线程技术,进程A中线程1向管道A写数据,进程B中线程2从管道A读数据,进程A线程2从管道B中读数据,进程B中线程1往管道B中写数据。 //利用多线程与有名管道技术,实现两个进程之间发送即 阅读全文

posted @ 2016-09-11 20:00 寒魔影 阅读(623) 评论(0) 推荐(0)

Linux 进程与线程四(加锁--解锁)

摘要: pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;int pthread_mutex_lock(pthread_mutex_t *mutex);int pthread_mutex_unlock(pthread_mutex_t *mutex);PTHREA 阅读全文

posted @ 2016-09-11 17:51 寒魔影 阅读(11811) 评论(0) 推荐(0)

Linux 进程与线程三(线程比较--创建线程参数)

摘要: int pthread_equal(pthread_t th1,pthread_t th2); pthread_equal函数比较th1与th2是否为同一线程,由于不可以讲pthread_t数据类型认为是整数,所以也不能用比较整数的方式比较pthread_t。 如果th1与th2相同,函数返回非0值,如果不同函数返回0。 线程属性 --以前调用pthread_create传入的attr参数都... 阅读全文

posted @ 2016-09-11 09:57 寒魔影 阅读(880) 评论(0) 推荐(0)

导航