Literature and Philosophy
Book List Literature 德 魔山 中 活着 Philosophy
MIT 6.S081 Lab syscall
Compulsory exercises Preparation reading To start the lab, switch to the syscall branch: 123$ git fetch$ git checkout syscall$ make clean System call tracing (moderate) 了解trace的过程 trace.c调用系统调用trace() 系统调用trace()调用sys_trace()设置进程的mask 理解mask的含义 mask作为作为系统调用序号的掩码,如mask = (1 << SYS_read) | (1 << SYS_fork)代表同时trace read 和 fork系统调用 当mask = 2147483647时代表trace序号1 - 31的系统调用 question: mask的类型? uint64 or uint32? 理论上都是可行的 添加编译依赖 添加trace系统调用 code ...
ChatGPT
Self Introduction GPT-4 is OpenAI’s most advanced system, producing safer and more useful responses. GPT4: I am a language model that is based on a neural network architecture known as GPT (Generative Pre-trained Transformer). This architecture is used in deep learning to generate natural language text by predicting the next word or sequence of words based on the input text. I was pre-trained on a large corpus of text and can generate human-like responses to a wide range of questions and prom...
gdb
Introduction gdb(GNU Debugger)是GNU项目中的调试工具。 Usage Common 帮助 help <command-name> 运行 run = r 运行到断点 c = continue 继续到断点 断点 b <breakpoint-name> 函数名处打断点 b <location> 在地址处打断点 步进 s C语言步进 进入函数 si 汇编语言步进 进入函数 n C语言步进 不进入函数 ni 汇编语言步进 不进入函数 观察点 打印内存: 使用x命令来打印内存的值,格式为x/nfu addr,以f格式打印从addr开始的n个长度单元为u的内存值。 x/nfu <address> n:输出单元的个数 f : 输出格式,如x表示以16进制输出,o表示以8进制数处,默认x,如果地址所指的是字符串,那么格式可以是s,如果地址是指令地址,那么格式可以是i。 u:一个单元的长度,b表示1byte,h表示2byte(half word),w表示4byte,g表示8byte(giant ...
tmux
Usage 在shell中 1$ tmux ctrl-b c 新建窗口 ctrl-b p 前一个窗口 ctrl-b n 下一个窗口 ctrl-b % 垂直拆分窗口 ctrl-b " 水平拆分窗口 ctrl-b o 在窗口间切换 exit 退出tmux
MIT 6.S081 Lecture 5: GDB, calling conventions and stack frames RISC-V
Reading Read Calling Convention C -> RISC-V Asm C -> Asm -> Binary (.c) -> (.s) -> (object / .o) RISC-V vs x86-64 x86-64 3本书 +3inst / month CISC RISC-V 2本书 更少更简单的指令 开源 RISC ARM Android ios RISC gdb 见gdb一文 Register 寄存器列表 经典的RISC-V函数 prologue保存callee saved register body函数体 epilogue还原callee saved register Stack Frame 栈帧 重要的两个register sp -> bottem of stack fp -> top of current frame struct 连续的内存结构,看成可变数据类型的数组
MIT 6.S081 Lecture 4: Page tables
Reading Read Chapter3 read code Address Spaces 每个进程拥有专属的地址空间 Page table实现了同一个物理内存,不同的地址空间 读写satp寄存器是特殊权限指令 PT H/W 不为每个地址(1Byte)创建表单条目,而为每个Page(通常4KB,Offset12位)创建一个表单条目 VA -> PA Real paging H/W (RISC-V) 三级缓存的RISC-V Page TLB: Translation Lookaside Buffer cache of PTE(page table entry) When switch PT, clear TLB OS and PTE OS可以操纵PTE Page Fault很有用 虚拟地址映射到内存和I/O设备 高于0x80000000 -> DRAM 低于0x80000000 -> I/O
MIT 6.S081 Lecture 3: OS organization and system calls
Reading Read Chapter2 read code Isolation 如果没有OS隔离,用户应用直接与硬件交互,难以实现Multiplexing Unix Interface 抽象关系 OS -> H/W process -> CPU exec -> Memory files -> disk block Defensive Isolation between apps and OS HW support user / kernel mode user mode被允许执行add sub等指令,而kernel mode被允许执行受限指令 virtual memory Virtual Memory Page table将虚拟地址映射到物理地址 每个独立的进程有独立的page table,因此实现了不同进程间的内存隔离 Kernel Kernel -> TCB(可信任的计算空间) 无bug 把apps当作恶意的 内核架构 宏内核(Linux) 微内核(两倍跳转,低performan...
MIT 6.S081 Lecture 2: C and gdb
Reading C Intro to C gdb Using the GNU Debugger
MIT 6.S081 Lecture 1: Introduction and examples
Reading Read Chapter1 OS purpose Abstract H/W Multiplex Isolation Sharing Security Performance Range of uses Classic design 内核 用户层隔离的设计 Why OS hard and interesting? unforgiving tension efficient - abstract powerfull - simple flexible - secure 文件交互和进程交互 program example using Sys Call example copy.c 使用read write exit系统调用 fd文件描述符(标准输入输出也只是文件而已) 0 stdin 1 stdout 2 stderr open.c 使用open write exit系统调用 sh.c shell可以被认为仅仅是执行标准输入的命令并打印到标准输出的用户程序 for...