非阻塞的程序 应该保障的一些特性 : 等待无关性wait-free:能确保每次的调用在有限的步数之内完成,不管其他调用的步骤有多少。杀掉几个线程 锁无关性lock-free:执行这段程序的某些线程会被延迟,但必须确保至少...
分类:
其他好文 时间:
2014-07-22 09:10:35
阅读次数:
374
第十一章 动态内存分配
数组在声明的时候,本身作为一个指针常量,它在编译时候内存就已经被分配好了。但是有时候程序不知道这个数组到底有多长,所以,为了防止内存的浪费,C提供了动态内存分配的策略。
其实,作为独立的一章,本章显得内容不多。malloc,free,calloc,realloc就没有了,但是它包含很多用法,也有很多陷阱。
总结:
malloc和calloc函数都用于动态分配...
分类:
其他好文 时间:
2014-07-21 23:23:53
阅读次数:
265
#include
#include
#include
#include
#include
using namespace std;
int h[20][20];
int v[20][20];
int size_[20];
int n,m;
int flag;
void judge(int x,int y)//这是关键部分的代码,用来判读那是否能构成square;
{
int a1=n-x...
分类:
其他好文 时间:
2014-07-21 13:36:09
阅读次数:
221
Reference: http://blog.csdn.net/lbyxiafei/article/details/9375735题目:Implement int sqrt(int x).Compute and return the square root of x.题解: 这道题很巧妙的运用了二....
分类:
编程语言 时间:
2014-07-21 11:22:09
阅读次数:
293
直接上代码 struct People{
int age;
}
int main(){
struct People * p= malloc(sizeof(struct Perople));
p->age=10;
struct People * p1=p;
p-age=12;
printf("%d\n",p1->age);
free(p);
return 0;
}
} 函...
分类:
编程语言 时间:
2014-07-21 10:22:57
阅读次数:
222
Square City is a very easy place for people to walk around. The two-way streets run North-South or East-West dividing the city into regular blocks. Most street int...
分类:
其他好文 时间:
2014-07-20 22:33:53
阅读次数:
295
在静态存储区:内存的分配在程序执行前就分配好了,在程序运行的过程中一直存在,如全局变量,和static声明的变量。 在栈中:内存的分配是在程序的运行过程中被分配,函数结束后系统自动释放。 在堆中:即动态分配,一般用malloc和new分配内存的大小,程序员自己用free和delete自己释 放, 因...
分类:
编程语言 时间:
2014-07-20 22:04:42
阅读次数:
215
今天来到公司就有销售反应很多客户反应网站访问很慢,于是乎赶紧自己访问一下试试,果然慢的出奇,于是开始排查:
1、查看系统基本性能:内存、cpu、磁盘
free-m查看内存(内存没有问题)
top查看cpu负载情况(负载很低)
df-h查看磁盘(磁盘只用了20%)
因此可以判断..
分类:
Web程序 时间:
2014-07-20 10:47:28
阅读次数:
263
previous:[工作记录] Android OpenGL ES 2.0: square texture not supported on some devicerecently I found that it is the mipmap of a non-square texture thatc...
分类:
移动开发 时间:
2014-07-19 23:09:07
阅读次数:
260