linux 环境编程
文章平均质量分 68
真胖子
这个作者很懒,什么都没留下…
展开
-
多处理器,多任务 的 同步
1. 多线程访问共享变量的竞争// This program demonstrates the need for synchronization among// cooperating threads in a multithreaded application. Several// threads here will separately increment a shared coun原创 2014-03-18 19:07:58 · 718 阅读 · 0 评论 -
C语言文件操作函数
转自clearerr(清除文件流的错误旗标) 相关函数 feof表头文件 #include 定义函数 void clearerr(FILE * stream); 函数说明 clearerr()清除参数stream指定的文件流所使用的错误旗标。 返回值 fclose(关闭文件) 相关函数 close,fflush,fopen,setbuf 表头文件 #in转载 2014-06-21 11:45:12 · 560 阅读 · 0 评论 -
fread和fwrite注意
fwrite(将数据写至文件流)定义函数 size_t fwrite(const void * ptr,size_t size,size_t nmemb,FILE * stream);函数说明 fwrite()用来将数据写入文件流中。参数stream为已打开的文件指针,参数ptr 指向欲写入的数据地址,总共写入的字符数以参数size*nmemb来决定。Fwrite()会返回实际写入转载 2014-06-21 11:49:43 · 1172 阅读 · 0 评论 -
c 语言编译器 (32bit测试)对整数类型long long截断
#include int main (){ long long a = 0x123456789a; printf("%llx\n",a); printf("%d %d %d\n", sizeof(long), sizeof(int), sizeof(long long)); return 0;}原创 2014-06-22 12:39:12 · 1090 阅读 · 0 评论 -
C语言运算符 优先级
运算符优先级不是运算优先级,而是结合性优先级,意指:高优先级的运算符所结合的变量或表达式,不能被低优先级的运算符分离。优先级决定运算符和哪些子表达式结合,表达式在取值时,按照递推结合,递归返回的顺序运算,所以编译器会先处理优先级低的运算符。原创 2014-07-07 15:03:28 · 454 阅读 · 0 评论 -
程序执行时间 测量
1. gettimeofdaystruct timeval t1,t4; gettimeofday(&t1,NULL); //... gettimeofday(&t4,NULL); printf("\n%d\n",(1000000*(t4.tv_sec-t1.tv_sec)+(t4.tv_usec-t1.tv_usec))/10000); //us2.rdtsc******原创 2014-03-18 21:30:15 · 529 阅读 · 0 评论 -
linux 时间度量
1. gettimeofdaystruct timeval t1,t4; gettimeofday(&t1,NULL); //... gettimeofday(&t4,NULL); printf("\n%d\n",(1000000*(t4.tv_sec-t1.tv_sec)+(t4.tv_usec-t1.tv_usec))/10000); //us2.rdtsc****转载 2014-03-18 19:19:02 · 655 阅读 · 0 评论 -
fork ,exit printf 的两次输出
#include "light.h"int main(int argc, char *argv[]){ printf("Hello world\n"); write(STDOUT_FILENO, "Ciao\n", 5); if (fork() == -1) errExit("fork"); /* Both child and parent c转载 2014-03-20 09:55:26 · 616 阅读 · 0 评论 -
nanosleep 纳秒级延迟
1. nanosleep 测试函数的原型如下:int clock_gettime(clockid_t clk_id, struct timespect *tp);clockid_t clk_id用于指定计时时钟的类型,对于我们Programmer以下三种比较常用:CLOCK_REALTIME, a system-wide realtime clock.CLOCK_PROCE原创 2014-03-18 21:19:17 · 2523 阅读 · 2 评论 -
c 左值右值
http://blog.csdn.net/code_crash/article/details/7038292原创 2014-09-18 17:25:32 · 430 阅读 · 0 评论