摘要:
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 != 阅读全文
摘要:
内核在创建进程的时候,在创建task_struct的同时,会为进程创建相应的堆栈。每个进程会有两个栈,一个用户栈,存在于用户空间,一个内核栈,存在于内核空间。当进程在用户空间运行时,cpu堆栈指针寄存器里面的内容是用户堆栈地址,使用用户栈;当进程在内核空间时,cpu堆栈指针寄存器里面的内容是内核栈空间地址,使用内核栈。 阅读全文