p1-search
search problemsstate spaces&search problemsstate spaces: The set of all possible states that are possible in your given worldtransition model: output the next state when the specific action is taken at current statecost: Incurred when moving from one state to another after applying an actionstart state -> goal test
state space graphsA state space graph is constructed with states repre senting nodes, with directed edges existing from a state to its children.These edges represent actions , ...
CSAPP-Chap8-Exceptional Control Flow
OS
There are three components in computer hardware systems
Processor, main memory and I/O devicesOS:
is a program that manages the computer hardware
also provides a basis for application programs
and acts as an intermediary between a user of a computer and the computer hardware
2 primary purposes:
Protect hardware from misuse by applications
Provide applications with simple and uniform mechanisms for manipulating hardware devices![[Pasted image 20240710111247.png]]![[Pasted image 20240813 ...
CSAPP-Chap3 程序的机器级表示
主要学习内容:x86汇编
程序编码编译代码:linux> gcc -Og -o p p1.c p2.c-Og 指使用机器代码实际编译流程:首先, 预处理器扩展源代码,插入所有用巨nelude 命令指定的文件,并扩展所有用 #define 声明指定的宏。其次,编译器产生两个源文件的汇编代码,名字分别为 pl. p2.s 。接下来,汇器会将汇编代码转化成二进制目标代码文件 pl.a p2.o 目标代码是机器代码的一种形式,它包含所有指令的二进制表示,但是还没有填入全局值的地址。最后,链接器将两个目标代码文件与实现库函数(例如 printf) 的代码合并,并产生最终的可执行代码文件(由命令行指示符 -op 指定的)。可执行代码是我们要考虑的机器代码的第二种形式,也就是处理器执行的代码格式
机器级代码x86-64 的机器代码和原始的 代码差别非常大。一些通常对 语言程序员隐藏的处理器状态都是可见的:
程序计数器(通常称为 “PC”, x86-64 中用%豆 表示)给出将要执行的下一条指令在内存中的地址。
整数寄存器(register)文件包含 16 个命名的位置,分别存储 64 位的值 ...
CSAPP-Chap2 信息的表示和处理
信息存储大部分计算机使用8位的块(字节)作为访问内存单独的位。内存:很大的数组(虚拟内存(virtual memory)),字节位置即为地址
字数据大小每台计算机都有一个字长 (word size), 指明指针数据的标称大小 (nominal size)字长决定系统虚拟地址空间大小; 最近 32位->64位的迁移数据类型可能因为32位或者64位而大小不同(int, char, …)。 因此,C语言给了一堆特定大小的数据类型(int32_t, int64_t…)
寻址和字节顺序大端法和小端法:—最低有效字节在最前面的方式,称为小端法 (little endian)最高有效字节在最前面的方式,称为大端法 (big endian)网络传输数据可能有错误ps: typedef声明:给数据类型命名e.g.: typedef int *int_pointer;
布尔代数简介&C语言中的按位计算![[Pasted image 20240630093522.png]]![[Pasted image 20240630093539.png]]| 就是 OR( 或),&就是 AND( 与),~ ...
61C-P5-CPU
SDS and boolean algebraSDSThe hardware underlying almost every processor is a Synchronous Digital System(SDS).
Synchronous: All operations coordinated by a central clock
Digital: Represent all values by discrete values— specifically, as binary digits 1 and 0
boolean signalsOn a chip/PC board, wires (i.e., electrical nodes) provide electrical signals and are used to represent variables. A wire can take on different values at different points in time.
Use voltage levels to signal 0 or 1 (w ...
61C-P4-CALL
CALL(Compiling, Assembling, Linking and Loading)p.s.: you can see [here](计组学习08——CALL - ZzTzZ - 博客园 (cnblogs.com)) for Chinese version for better understanding.![[Pasted image 20240624150906.png]]For C, compiling is actually multiple steps:compiling .c files to .o files,automatic assembling,then linking the .o files into executables.
Step1: compilerinput: high-level language code (foo.c)output: assembly (foo.s)pseudo-intsturctions (伪指令) might be included
Step2: assemblerinput: assemblyoutput: m ...
PA1-notes
advanced makelscpu to see how many CPUs have in your computerthen, add -j? after the make to make the project run in multiple machinesccache: store the compiled file after it have been deleted by make clean
PA1overviewWhat should be done in PA:
12345678910111213 +---------------------+ +---------------------+ | Super Mario | | "Hello World" | +---------------------+ +---------------------+ ...
PA0-notes
Very Basic VimYou can edit /etc/vim/.vimrc for settingsorigin mode, insert mode, quit mode
origin modemain usage:h,j,k,l for the movingi for entering insert modefor entering the quit modeinsert modejust like the origin windows one
quit mode:w for saving:q for quitting
Makefile本质:描述有向无环图BASIC rule:target file: dependent file instructions
first example: hello world123456789hello:hello.o gcc hello.o -o hello hello.o:hello.c gcc -c hello.c -o hello.o .PHONY: clear: rm hello.o hello.S he ...
functions
template functionsfunctions whose functionality can be adapted to more than one type or class without repeating the entire code for each type.
classes
classstruct and classAll these fields are public, i.e. can be changed by the user.Because of this, we can’t enforce certain behaviors in structs, like avoiding a negative age.In class:
users can access the public
users cannot access the private
define a classusing .h file!
.h: define functions
.cpp: implement logic.h file: 123456789101112class Student {private:std::string name;std::string state;int age;public:/// constructor for our studentStudent(std::string name, std::string state, int ...
