码迷,mamicode.com
首页 >  
搜索关键字:pthread    ( 1177个结果
pthread_cond_wait、pthread_cond_signal 不深入的思考
编程中,当涉及到多个线程需要访问同一个全局对象时,往往需要进行线程同步,而线程同步,往往是一个约定俗成的东西。比如说: 为了保持g_var的一致性,理应在所有线程改写其值时加锁保护,以防止其它线程同时对其进行修改而引发不好的行为。然而此时假如有某个线程,在改写全局对象g_var是并未加锁保护,或者使 ...
分类:其他好文   时间:2017-08-23 18:21:56    阅读次数:280
线程属性API
数据类型:pthread_attr_t 操作API: ...
分类:编程语言   时间:2017-08-22 17:32:39    阅读次数:144
线程绑定
#include<unistd.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include<pthread.h>#include <sched.h> #include<iostream> u ...
分类:编程语言   时间:2017-08-21 00:22:03    阅读次数:192
线程同步API
头文件:<pthread.h> 编译记得加 -lpthread库 1:互斥锁(mutex) 数据类型:pthread_mutex_t 操作API: 2:读写锁 数据类型:pthread_rwlock_t 操作API: 注:读写锁适合使用在临界资源读频率远高于写频率的情况下。 当临界资源位于读锁定情况 ...
分类:编程语言   时间:2017-08-21 00:14:42    阅读次数:220
自旋锁,读写锁和顺序锁的实现原理
常用的同步原语锁,到多核处理器时代锁已经是必不可少的同步方式之一了。无论设计多优秀的多线程数据结构,都避不开有竞争的临界区,此时高效的锁显得至关重要。锁的颗粒度是框架/程序设计者所关注的,当然越细越好(也不尽然),同时不同的锁往往也会体现出完全不同的效率,Linux有posix的pthread_mu ...
分类:其他好文   时间:2017-08-20 15:45:28    阅读次数:541
Linux多线程编程 - sleep 和 pthread_cond_timedwait
#include <stdio.h> #include <stdlib.h> int flag = 1; void * thr_fn(void * arg) { while (flag){ printf("******\n"); sleep(10); } printf("sleep test thr ...
分类:编程语言   时间:2017-08-19 12:47:21    阅读次数:318
多线程同步
概念:多个线程按照规定的顺序来执行,即为线程同步 扫地5次后拖地模型 #include<pthread.h>#include<stdio.h> pthread_mutex_t mut;pthread_t thread[2];int number=0; void studentA(){ int i; ...
分类:编程语言   时间:2017-08-16 15:21:48    阅读次数:155
多线程程序设计
工人1 /2干活模型程序设计 #include<pthread.h>#include<stdio.h> pthread_t thread[2];int number=0;pthread_mutex_t mut;void *worker1(){ int i =0; printf("i am worke ...
分类:编程语言   时间:2017-08-16 11:24:32    阅读次数:228
open-falcon 安装Dashboard时候报错"SSLError: The read operation timed out"
在部署open-falcon环境过程中,安装Dashboard时候报错"SSLError: The read operation timed out"。如下: 解决办法:在命令后面追加"-i http://pypi.doubanio.com/simple" ...
分类:其他好文   时间:2017-08-13 23:26:11    阅读次数:280
Cocos2dx 3.0 过渡篇(二十七)C++11多线程std::thread的简单使用(下)
本篇接上篇继续讲:上篇传送门:http://blog.csdn.net/star530/article/details/24186783简单的东西我都说的几乎相同了,想挖点深的差点把自己给填进去。以下实际演练一下。请同意我參考偶尔E往事的一篇线程的博客, 他用的是pThread。这里我就用std:: ...
分类:编程语言   时间:2017-08-13 18:39:24    阅读次数:203
1177条   上一页 1 ... 31 32 33 34 35 ... 118 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!