摘要: 1.sizeof()函数的一些思考测试代码如下:#include #include int main(void){ int* nptr1; int* nptr2 = NULL; int* nptr3 = malloc(5*sizeof(int));//重点是这个,sizeof(np... 阅读全文
posted @ 2013-05-23 22:14 独墅一枝花 阅读(194) 评论(0) 推荐(0) 编辑
摘要: malloc(0)返回是什么?测试代码如下:#include <stdio.h>#include <stdlib.h>int main(void){ int* nptr = NULL; printf("%p ", nptr); if( nptr == NULL ) { printf( "现在是空的\n" ); } nptr = malloc(0); printf("用malloc(0)赋值之后\n"); printf("%p ", nptr);//地址的输出格式是%p if( nptr != 阅读全文
posted @ 2013-05-23 21:59 独墅一枝花 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 内核在创建进程的时候,在创建task_struct的同时,会为进程创建相应的堆栈。每个进程会有两个栈,一个用户栈,存在于用户空间,一个内核栈,存在于内核空间。当进程在用户空间运行时,cpu堆栈指针寄存器里面的内容是用户堆栈地址,使用用户栈;当进程在内核空间时,cpu堆栈指针寄存器里面的内容是内核栈空间地址,使用内核栈。 阅读全文
posted @ 2013-05-23 15:29 独墅一枝花 阅读(200) 评论(0) 推荐(0) 编辑