├── .gitattributes ├── CS201 离散数学.one ├── CS201 离散数学.pdf ├── CS202 计算机组成原理.one ├── CS202 计算机组成原理.pdf ├── CS208 算法设计与分析.one ├── CS208 算法设计与分析.pdf ├── CS316 分布式与云计算.one ├── CS316 分布式与云计算.pdf ├── OS Cheating Paper.pdf ├── OS Review Outline (Indigrid).txt ├── OS.one ├── OS.pdf ├── SS042 世界建筑.one ├── SS042 世界建筑.pdf └── readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.one filter=lfs diff=lfs merge=lfs -text 2 | *.pdf filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /CS201 离散数学.one: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:adbf22121e9af2ec38179c8e2771501867e78ad324b27b6d139f1578876fe1d3 3 | size 58842264 4 | -------------------------------------------------------------------------------- /CS201 离散数学.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:32e91d7808a8ebb6504a9bc58c773fdd48b77047f4e476afec9ca5417b337c94 3 | size 14745431 4 | -------------------------------------------------------------------------------- /CS202 计算机组成原理.one: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f7f5cea60fe60659ae4aaf6083f162b3f4a1a98efae2358113f37d5f55f4418e 3 | size 13192248 4 | -------------------------------------------------------------------------------- /CS202 计算机组成原理.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:af078c7910639ea6b3baadd351935d3c5e2210cca78ae63c697c149c9578e2cf 3 | size 4738487 4 | -------------------------------------------------------------------------------- /CS208 算法设计与分析.one: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6a1745c0cd10171cc835ab2bc194a0d80a00a9b105f6ff0cdbe1dbeea451f772 3 | size 31171624 4 | -------------------------------------------------------------------------------- /CS208 算法设计与分析.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:236158fce69d5477b902a2c236d522fa86c9cab34adc5f47b1f81309b2a8e86c 3 | size 7948255 4 | -------------------------------------------------------------------------------- /CS316 分布式与云计算.one: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d07eb166b9eb6ac3f5abf86e123762904092b91f23b73da0e0ea816a7eaa2453 3 | size 10199192 4 | -------------------------------------------------------------------------------- /CS316 分布式与云计算.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:216bcfd9686e95b0384cd9f21583bf2038006f080c2c73320cb150e3d1d173f3 3 | size 1908010 4 | -------------------------------------------------------------------------------- /OS Cheating Paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerrylususu/LectureNotes/fcafdc8f0a78b13dbb7b6f4595b47c217470d753/OS Cheating Paper.pdf -------------------------------------------------------------------------------- /OS Review Outline (Indigrid).txt: -------------------------------------------------------------------------------- 1 | OS 复习 2 | 大架构 3 | 进程 4 | syscall 5 | 用户视角、内核视角 6 | 生命周期、调度 7 | 信号 8 | 同步、死锁 9 | 内存 10 | 虚拟内存、地址翻译 11 | 缓存 12 | 请求分页 13 | 存储 14 | I/O 15 | 文件系统 16 | 复习内容 17 | 课件 x12 18 | lab x? 19 | 期中试卷 x1 20 | 作业 x? report x9 21 | pop quiz 22 | onenote 图形笔记 23 | 去看看 unix call youtube视频 24 | 考前确认 25 | L5, schedule算法手动画图 26 | L6, 模拟p-c,哲学家就餐问题 27 | lab7 银行家算法模拟 28 | L8 P33 地址翻译模拟 29 | L9 P23 缓存模拟 30 | L10 P38 磁盘速度计算 31 | L10 P52 disk scheduling 模拟 32 | 未解决问题列表 33 | 信号的处理过程? 34 | 多个程序共享同一个对象的时候,什么算CS? 35 | A's CS != B's CS: L6-P28 36 | 银行家算法处理哲学家就餐问题? 37 | 资源分配图是啥? 38 | 没有环路不会死锁,出现环路可能死锁 39 | 如果只有一个资源实例,又出现了环路,就一定会死锁 40 | 资源分配图化简? 41 | 找一个只有分配边的进程节点(资源->进程) 42 | 找不到怎么办? 43 | 移除该节点和分配边,把资源分配给等待的进程 44 | 重复 45 | 如果能完全被化简,就没有死锁 46 | 程序从存储设备加载到内存的过程? 47 | 进程的调度方式? 48 | 缓存的替换方式? 49 | 进程和线程的区别? 50 | 为什么stack往下长 heap往上长 51 | concurrency?parallel? 52 | concurrency 并发,parallel 并行 53 | “并发”指的是程序的结构,“并行”指的是程序运行时的状态 54 | 并行计算、并发编程 55 | 判断程序是否处于并行的状态,就看同一时刻是否有超过一个“工作单位”在运行就好了。所以,单线程永远无法达到并行状态。 56 | 正确的并发设计的标准是:使多个操作可以在重叠的时间段内进行 57 | 并发设计让并发执行成为可能,而并行是并发执行的一种模式。 58 | https://laike9m.com/blog/huan-zai-yi-huo-bing-fa-he-bing-xing,61/ 59 | fork的 file,file locks? 60 | file descriptor: process中的一个int 61 | file description: kernel中描述file的一个struct,包括当前offset 62 | file lock: advasory 加在 file 上,mandatory 加在 inode 上 63 | 之前process lab上遇到的诡异问题是什么?bg/fg? 64 | Threads in a Process? L05P57 65 | 程序编译/运行全过程?L08-P14 66 | L8-P33 用到的 x86 汇编指令? 67 | L9-P19 Effective Access Time? Avg Access Time? 68 | EAT = Hit Time + Miss Rate x Miss Penalty 69 | L9-P28 LRU/MIN 下,小内存时cache的内容是大内存时的子集? 70 | L9最后的页面部分:P33-P35? 71 | L10-P4 Linux Memory Canonical Hole? 72 | L10-P36 数值错误? 73 | 对比 ext2/3 和 fat? 74 | L12-P4:VS. FAT: pointers of a file are 75 | 已经解决 76 | system = fork + exec + wait 77 | stack在上的内存布局被叫做什么:L1P29 segmentation 78 | PCB存储在kernel中的数据结构:双向链表 79 | wait,waitpid 80 | wait:任何一个children,只管termination 81 | waitpid:指定某一个child,可以监听多种状态改变 82 | 作用:暂停parent、清理child 83 | time 的计时问题,什么时候多,什么时候少 84 | real 真实耗时,user 用户模式下CPU时间,sys kernel模式下CPU时间 85 | user+sys只是CPU时间 86 | 这三个值都是包含子进程的(如果可能,例如用了 wait/waitpid) 87 | real < user+sys:多线程+多核 88 | real > user+sys:IO-intensive,调度其他程序,mode切换overhead 89 | syscall可能同时使用user和sys:可能需要数据处理:https://stackoverflow.com/a/556411 90 | scheduling,context switching 91 | schedule:决定下一个要运行的进程 92 | context switch:真正的切换过程 93 | hyperthreading 94 | 在OS层面上,线程的实现本身就是软件上降低依赖性,提升并发度的方法。而“假装自己是两个处理器”是最简单的硬件解耦,于是HT技术就这么产生了。首先解码逻辑核心1的机器码,送入执行单元,等待结果的同时解码逻辑核心2的机器码,如果出现的空闲的执行单元恰好是逻辑核心2的微码需要的,就直接送入执行单元不必一定要等待逻辑核心1的代码完全执行完毕。这一来一去,两个逻辑核心变得相对独立了。 95 | https://zhuanlan.zhihu.com/p/58448264 96 | Multiprocessing,Multiprogramming,Multithreading 97 | Multiprocessing  Multiple CPUs 98 | Multiprogramming  Multiple Jobs or Processes 99 | Multithreading  Multiple threads per Process 100 | 进程间通信的方式?一共有几种? 101 | Shared file 102 | Pipe/FIFO 103 | Shared memory 104 | Semaphore 105 | Shared file? 106 | Message passing 107 | Signal 108 | Message queue 109 | Socket 110 | MPI 111 | sem_close,sem_unlink 112 | sem_close: close's a semaphore, this also done when a process exits. the semaphore still remains in the system. 113 | sem_unlink: will be removed from the system only when the reference count reaches 0 (that is after all processes that have it open, call sem_close or are exited). 114 | 前者是语义上的,后者是文件系统中的 115 | binary semaphore,mutex 116 | • Mutex is more about resource protection. 117 | • Semaphore is more about resource assignment. 118 | • Mutex can only be unlock by container. 119 | • Semaphore can be assigned by anyone, including caller itself. 120 | • Mutex lock will be released, if the holder is terminate. 121 | • Semaphore will not add up, if the holder is terminate. 122 | conditional varible 123 | Cond = a condition + a mutex 124 | 使用时间:when If/else is unbalance 125 | Reader/Writer 问题 126 | W: semaphore wrt=1 127 | writer: wait wrt, write, signal wrt 128 | R: int readcnt=0, semaphore mutex=1 129 | 这个mutex只是锁readcnt的 130 | wrt才是控制文件写入的 131 | 因为reader之间是不干扰的 132 | reader 133 | wait mutex,readcnt++,如果是第一个就wait wrt阻止写入,然后signal mutex 134 | read 135 | wait mutex, readcnt--,如果没有剩下的reader就signal wrt允许写入,然后signal mutex 136 | 奇怪的知识点列表 137 | OS:kernel + driver, shell + util 138 | 存储 hierarchy:容量、延迟、带宽、价格 139 | OS的4个核心概念:thread, addr space (+trans), process, dual mode op/protection 140 | thread: single unique execution context + state 141 | process: execution instance of a program, execution environment with Restricted Rights ,有状态 142 | protection: control translation 143 | 读写内存地址的可能结果:nothing,正常,ignore,I/O操作,page fault, seg fault 144 | 触发context switch的因素:timer, I/O interrupt, signal, priority, voluntary yield, other 145 | OS的protection目标:reliability, security, privacy, fairness 146 | 切换Kernel/User的3种方式:syscall, interrupt, trap/exception 147 | fork的4变与5不变 148 | 不变(copy):pc/register, code, memory(copy on write), opened file 149 | 变:return value, PID, parent, running time, file locks 150 | 进程相关syscall实现 151 | fork的实现过程:PCB复制、PCB修改、内存复制(可能CoW)、改返回值 152 | exec实现:清空内存(userspace: local var + heap)、用新程序加载(reset: global var, code ,constant)、重设PC 153 | exit实现:1内核释放PCB、关闭opend files,1a如果有children、过继给init(改child parent_ptr, 改init child_list,应用background job),2user space memory释放,3进程zombie、发送SIGCHLD给parent 154 | wait实现:1注册SIGCHLD handler、2接收SIGCHLD信号、3接受并移除信号,把child完全从kernel-space移除、4删除handler,返回PID 155 | process 生命周期:created, ready, running, waiting/blocked([un]interruptable), terminated/zombie 156 | thread 生命周期:init, ready, running, waiting, finished 157 | context switch 的开销 158 | direct:保存/加载register,模式切换,地址空间切换 159 | indirect:CPU cache, buffer cache?, TLB miss 160 | schedule算法:FIFO, Shortest-Job-First(Preemptive, NP), Round-Robin, Priority + Multiple Queue, Priority + Multi Queue/Scheduler 161 | RC:共享对象 多个进程 同时访问 162 | CS实现:Mutual Exclusion, Bounded Wating (饥饿), Progress (死锁) 163 | 死锁条件:Mutual Exclusion, Hold and Wait, no Preemptation, Circular Wait 164 | 处理死锁策略:允许死锁恢复、避免死锁、忽略 165 | 已经死锁了:中止进程、抢占资源、回滚操作 166 | 避免死锁:无限资源、禁止共享、禁止等待、一开始申请好全部、特定顺序获取 167 | 死锁的检测:银行家算法 168 | remain 169 | 如果分配是否超过max 170 | 是否可以安全结束 171 | Memory Multiplexing的重点:Protection, Controlled Overlap, Translation 172 | 虚拟内存的实现方式:Base & Bound, Segmentation, Paging, Segment + Paging 173 | 缓存有用的前提:freq case 足够频繁, infreq case不太expensive 174 | 缓存有用的原因:spatial / temporal locality 175 | cache的关注点:block size, organization, 如何查找, replacement policy, miss处理, write处理 176 | organization: direct-mapped, set-associative, fully-associative,见L9-P41 177 | write处理: write-through, write back 178 | page fault处理:根据替换策略选择被替换的页、如果dirty写回、改PTE/TLB为invalid,加载新页,更新PTE并invalid旧 TLB项、从错误位置恢复 179 | belady anomaly: 增加cache size反倒会增加miss,看size小是否是size大的子集,FIFO会,LRU/MIN不会 180 | cache miss的种类:compulsory, capacity, conflict, policy 181 | page replacement policy: FIFO, MIN, RANDOM, LRU, approx LRU(clock, n-th clock, second chance [FIFO+LRU]) 182 | page frame allocation: Equal, Proportional, Priority 183 | IO设备的参数:数据粒度(byte, block), 访问模式(seq, random), 传输方式 (programmed IO, DMA) 184 | CPU控制IO设备的方式(连接方法):io instruction (in/out), memory-mapped IO (load/store) 185 | CPU和IO设备之间数据传输的方式(传输方法):programmed IO, Direct Memory Access 186 | IO设备通知OS:interrupt, polling 187 | IO评价标准:response time/latency, bandwith/throughput, start up/overhead 188 | 硬盘的物理组成:sector, track, cylinder 189 | 硬盘读写时间:(queuing time, controller time,) seek time (移到柱面), rotational latency (旋转到扇区), transfer time 190 | SSD 无 seek/rotaional time 191 | 比较SSD/HDD:pro: 延迟/吞吐,移动部件,读速度 con: 贵、asymmetric block write perf、limited lifetime 192 | Startup Cost for I/O:syscall overhead, OS processing, controller overhead, driver startup, queuing 193 | disk scheduling: FIFO, Shortest Seek Time First, SCAN, Circular-SCAN, LOOK, CLOOK 194 | FS的组成部分:naming, disk management, protection, reliability 195 | FS Layout: contiguous allocation, linked allocation, inode allocation 196 | 期末问题 197 | fork的实现过程 198 | 哪些方法可以实现 mutual exclusion?优缺点? 199 | Filter Algorithm Peterson's_algorithm:多进程 turn/interested 200 | 期末考试:一定会考至少一个 IPC 问题 201 | 银行家算法 202 | LRU -------------------------------------------------------------------------------- /OS.one: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerrylususu/LectureNotes/fcafdc8f0a78b13dbb7b6f4595b47c217470d753/OS.one -------------------------------------------------------------------------------- /OS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerrylususu/LectureNotes/fcafdc8f0a78b13dbb7b6f4595b47c217470d753/OS.pdf -------------------------------------------------------------------------------- /SS042 世界建筑.one: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:06bdd6be5f792ec451d75af14a96f2f15335ab3bd385f25706b46ad785435a72 3 | size 156861920 4 | -------------------------------------------------------------------------------- /SS042 世界建筑.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:977605717ca6ba09727907f9d7637bf2c5293574d9f173ee19216848e0be5fb0 3 | size 5234079 4 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 2018-2019 2 笔记 2 | 3 | **免责声明**:本人不对此笔记造成的任何误导负责!(包括但不限于:作业/考试中使用了错误的公式,读笔记后产生的错误理解等) 4 | 5 | ## 目录 6 | 7 | | 科目 | 最后更新章节 | 最后更新 | 链接 | 8 | | -------------------- | -------------------------------- | --------------- | ------------------------------------------------------------ | 9 | | CS201 离散数学 | 期中试卷解析、Quiz 2(新增) | 2019/6/3 23:52 | [one](https://github.com/jerrylususu/LectureNotes/blob/master/CS201%20%E7%A6%BB%E6%95%A3%E6%95%B0%E5%AD%A6.one), [pdf](https://github.com/jerrylususu/LectureNotes/blob/master/CS201%20%E7%A6%BB%E6%95%A3%E6%95%B0%E5%AD%A6.pdf) | 10 | | CS202 计算机组成原理 | L14 汉明码、虚拟内存(bug 修复) | 2019/6/3 23:52 | [one](https://github.com/jerrylususu/LectureNotes/blob/master/CS202%20%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86.one), [pdf](https://github.com/jerrylususu/LectureNotes/blob/master/CS202%20%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86.pdf) | 11 | | CS208 算法设计与分析 | 各章节问题总结 更新至 C3 图 | 2019/6/4 22:30 | [one](https://github.com/jerrylususu/LectureNotes/blob/master/CS208%20%E7%AE%97%E6%B3%95%E8%AE%BE%E8%AE%A1%E4%B8%8E%E5%88%86%E6%9E%90.one), [pdf](https://github.com/jerrylususu/LectureNotes/blob/master/CS208%20%E7%AE%97%E6%B3%95%E8%AE%BE%E8%AE%A1%E4%B8%8E%E5%88%86%E6%9E%90.pdf) | 12 | | CS316 分布式与云计算 | 虚拟化(完结) | 2019/5/29 20:58 | [one](https://github.com/jerrylususu/LectureNotes/blob/master/CS316%20%E5%88%86%E5%B8%83%E5%BC%8F%E4%B8%8E%E4%BA%91%E8%AE%A1%E7%AE%97.one), [pdf](https://github.com/jerrylususu/LectureNotes/blob/master/CS316%20%E5%88%86%E5%B8%83%E5%BC%8F%E4%B8%8E%E4%BA%91%E8%AE%A1%E7%AE%97.pdf) | 13 | | (*) SS042 世界建筑 | 巴洛克建筑(完结) | 2019/5/29 20:58 | [one](https://github.com/jerrylususu/LectureNotes/blob/master/SS042%20%E4%B8%96%E7%95%8C%E5%BB%BA%E7%AD%91.one), [pdf](https://github.com/jerrylususu/LectureNotes/blob/master/SS042%20%E4%B8%96%E7%95%8C%E5%BB%BA%E7%AD%91.pdf) | 14 | 15 | (*). 如果你复习时想要摸鱼... 16 | 17 | ## 须知 18 | 19 | 1. 这只是我自己的笔记,如果口味不符请**不要强迫自己阅读** 20 | 2. 有的内容可能尚未链接完成(如离散内的部分证明),稍后会逐步完善(应该是跟着我自己的复习进度) 21 | 3. 有错误/改进之处,请提出 issue 22 | 4. 笔记文件较大,故使用 Git Large File Support 23 | 24 | ## 更新日志 25 | 26 | 6/4 22:30: 算法新增「各章问题总结」 更新至 C3 图 27 | 28 | 6/3 23:52: 离散更新内容:期中试卷解析、Quiz 2; 计组 L13 bug 修正 29 | 30 | 6/2 19:15: 离散 C7~C8 内容补充 31 | 32 | 6/2 11:17: 计组 L13-L14 内容补充 33 | 34 | 6/2 9:28: 计组 L9~L12 内容补充,另附 6/1 答疑部分问题合集(未整理) 35 | 36 | 6/1 0:19: 离散 C6 内容补充 37 | 38 | ## 格式说明 39 | 40 | | 格式 | 说明 | 41 | | ------------------------- | ------------------------------------------------------------ | 42 | | `.one` OneNote 笔记本文件 | 最推荐使用。完整保留原始格式。需要桌面版或 UWP 版本 OneNote。 | 43 | | `.pdf` | 仅当你用不了 OneNote 的时候选择。极大概率会出现排版错乱。 | 44 | 45 | ## 版权说明 46 | 47 | | 内容 | 版权 | 48 | | ------------- | ------------------------------------------------ | 49 | | 课件/课本图片 | 归对应课程任课老师/课本出版社所有 | 50 | | 外部内容 | 归外部版权所有者所有 | 51 | | 笔记主体内容 | CC-BY-NC-SA 4.0 (署名-非商业使用-相同方式共享) | 52 | 53 | --------------------------------------------------------------------------------