2018年6月18日

线程高级编程

摘要: 一次性初始化 pthread_once_t once_control = PTHREAD_ONCE_INIT;//控制参数,用来确定是否已调用相关的初始化例程。 int pthread_once(pthread_once_t *once_control,void (*init_routine)(vo 阅读全文

posted @ 2018-06-18 14:13 tianzeng 阅读(3990) 评论(0) 推荐(0) 编辑

time函数及其用法

摘要: st_atime:文件中的数据最后被访问的时间 Time when file data was last accessed. Changed by the following functions: creat(), mknod(), pipe(), utime(2), and read(2). st 阅读全文

posted @ 2018-06-18 12:13 tianzeng 阅读(13468) 评论(0) 推荐(0) 编辑

2018年6月17日

pthread调度策略,优先级和竞争范围

摘要: 实时调度:操作系统在有限的时间内提供特定水平的服务能力。受限制的响应时间不一定是块的反应,意味着可预知的响应速度。如果系统定义_POSIX_THRAED_PRIORITY_SCHEDULING,它为线程指派实时调度优先级提供支持。支持_POSIX_THRAED_PRIORITY_SCHEDULING 阅读全文

posted @ 2018-06-17 13:21 tianzeng 阅读(8213) 评论(0) 推荐(0) 编辑

2018年6月13日

c++中for的四种用法

摘要: #include <algorithm> #include <vector> #include <iostream> using namespace std; int main() { int nArray[] = {0, 1, 2, 3, 4, 5}; std::vector<int> vec(n 阅读全文

posted @ 2018-06-13 22:50 tianzeng 阅读(10857) 评论(0) 推荐(1) 编辑

2018年6月8日

同步

摘要: 互斥量 #include <pthread.h> pthread_mutex_t mutex=PTHREAD_MUTEX_INTIIALIZER; int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexa 阅读全文

posted @ 2018-06-08 23:08 tianzeng 阅读(1991) 评论(0) 推荐(0) 编辑

2018年6月7日

排列算法(reverse...rotate...next_permutation)

摘要: reverse template <class BidirectionalIterator> void reverse(BidirectionalIterator first,BidirectionalIterator last)//翻转range内iterator所指的元素而非iterator本身 阅读全文

posted @ 2018-06-07 16:59 tianzeng 阅读(264) 评论(0) 推荐(0) 编辑

2018年5月19日

const_cast

摘要: 函数原型: const_cast < type-id > ( expression ) 去掉const属性:const_cast<int*> (&num),常用,因为不能把一个const变量直接赋给一个非const变量,必须要转换。 加上const属性:const int* k = const_ca 阅读全文

posted @ 2018-05-19 23:21 tianzeng 阅读(9998) 评论(0) 推荐(2) 编辑

2018年5月14日

c++中的流

摘要: streambuf类为缓冲区提供内存,并提供了用于填充缓冲区,访问缓冲区,刷新新缓冲区和管理缓冲区内存的类方法。 ios_base类表示流的一般特征,如是否可读,是二进制还是文本流等。 ios类基于ios_base,其中包括了一个之指向streambuf对象的的指针成员。 缓冲区介绍 输入:从磁盘上 阅读全文

posted @ 2018-05-14 23:58 tianzeng 阅读(4468) 评论(2) 推荐(2) 编辑

c++从string类型转换为bool类型

摘要: 利用输入字符串流istringstream bool b; string s="true"; istringstream(s)>>boolalpha>>b;//boolalpha>>必须要加 cout<<boolalpha<<b<<endl; 但当字符串s为“1”时,上面的代码无法正确转换,此时应该 阅读全文

posted @ 2018-05-14 23:39 tianzeng 阅读(7088) 评论(0) 推荐(0) 编辑

结构体字节对齐方式

摘要: 内存对齐规则 变量(结构体变量)的起始地址能够被其对齐值整除,结构体变量的对齐值为最宽的成员大小 结构体每个成员相对于起始地址的偏移能够被其自身对齐值整除,如果不能则在前一个成员后面补充字节 结构体总体大小能够被最宽的成员的大小整除,如不能则在后面补充字节 此外还有编译器的默认对齐值,一般默认对齐值 阅读全文

posted @ 2018-05-14 22:01 tianzeng 阅读(6280) 评论(0) 推荐(0) 编辑

导航