- 博客(13)
- 收藏
- 关注
原创 CSAPP学习日志11:系统级 I/O
Unix I/O一个Linux文件就是一个m个字节的序列,所有的I/O设备(例如网络、磁盘和终端)都被模型化喂文件,而所有的输入和输出都被当作对相应文件的读和写来执行。这种将设备映射为文件的方式,允许Linux内核引出一个简单、低级的应用接口,称为Unix I/O,这使得所有的输入和输出都能以一种统一且一致的方式来执行:打开文件:一个应用程序通过要求内核打开相应的文件,来宣告它想要访问一个I...
2019-12-09 00:52:38
142
原创 CSAPP学习日志10:链接
目标文件目标文件有三种形式:可重定位目标文件:包含二进制代码和数据,其形式可以在编译时与其他可重定位目标文件合并起来,创建一个可执行目标文件。可执行目标文件:包含二进制代码和数据,其形式可以被直接复制到内存并执行。共享目标文件:一种特殊类型的可重定位目标文件,可以在加载或者运行时被动态地加载进内存并链接。编译器和汇编器生成可重定位目标文件(包括共享目标文件)。链接器生成可执行目标文件。...
2019-12-08 23:03:52
129
原创 CSAPP学习日志9:fork
关于fork函数的一些说明①fork函数的定义:`pid_t Fork (void){ pid_t pid; if((pid = fork())<0) unix_error("Fork error"); return pid;}②pid_t 类型在 Linux 环境编程中用于定义进程 ID,实质是int类型,定义在头文件<sys/types.h>中;③for...
2019-12-08 20:56:33
152
原创 CSAPP学习日志8:bufdemo
代码全览/* Demonstration of buffer overflow */#include <stdio.h>#include <stdlib.h>/* Implementation of library function gets() */char *gets(char *dest){ int c = getchar(); char *p ...
2019-05-31 22:49:39
97
原创 CSAPP学习日志7:runaway
代码全览/* Example of deep recursion */#include <stdio.h>#include <stdlib.h>int recurse(int x) { int a[1<<15]; /* 4 * 2^15 = 64 KiB */ printf("x = %d. a at %p\n", x, a); ...
2019-05-31 21:39:32
224
原创 CSAPP学习日志6:locate
代码全览#include <stdlib.h>#include <stdio.h>#include <unistd.h>static void show_pointer(void *p, char *descr) { // printf("Pointer for %s at %p\n", descr, p); printf("%s...
2019-05-31 17:18:24
105
原创 CSAPP学习日志5:hexify
代码全览/* Convert sequence of hex digits on command line into a string, terminated by \n */#include <stdio.h>int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { u...
2019-05-31 15:55:30
121
原创 CSAPP学习日志4:struct
代码全览#include <stdio.h>#include <stdlib.h>typedef struct { int a[2]; double d;} struct_t;double fun(int i) { volatile struct_t s; s.d = 3.14; s.a[i] = 1073741824;...
2019-05-31 15:06:30
217
原创 CSAPP学习日志2:Sq
代码全览#include <stdio.h>#include <stdlib.h>int sq(int x) { return x*x;}int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; i++) { int x = atoi(argv[i]); i...
2019-05-30 01:22:46
225
原创 CSAPP学习日志3:fsum
代码全览#include <stdio.h>#include <stdlib.h>#include <string.h>#define BUFSIZE 256int main(int argc, char *argv[]) { char prefix[BUFSIZE]; char next[BUFSIZE]; int i; ...
2019-05-30 01:14:24
129
原创 CSAPP学习日志1:show_bytes
代码全览/* show-bytes - prints byte representation of data *//* $begin show-bytes */#include <stdio.h>/* $end show-bytes */#include <stdlib.h>#include <string.h>/* $begin show-byt...
2019-05-28 23:49:34
311
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人