Loading

摘要: Lab: Multithreading Uthread: switching between threads 实现一个用户级线程,跟内核线程的切换没什么区别。只要上课听懂了,复制内核代码就行了 只贴关键代码 线程上下文 struct context { uint64 ra; uint64 sp; / 阅读全文
posted @ 2022-01-08 15:24 traver 阅读(55) 评论(0) 推荐(0) 编辑
摘要: Lab: Copy-on-Write Fork for xv6 实现xv6中的写时复制 Virtual memory provides a level of indirection: the kernel can intercept memory references by marking PTEs 阅读全文
posted @ 2022-01-08 15:22 traver 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Lab: xv6 lazy page allocation 实验的三个部分,逐步实现一个lazy allocation,我就按照自己的思路写,不分三个部分了 修改sbrk() 不直接分配物理内存,这也就是lazy allocation最本质的地方 n>0 只改变p->sz n<0 改变p->sz同时 阅读全文
posted @ 2021-12-30 16:09 traver 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Lab: traps RISC-V assembly 有关RISC-V的汇编,分析call.c中的代码 call.c: int g(int x) { return x+3; } int f(int x) { return g(x); } void main(void) { printf("%d %d 阅读全文
posted @ 2021-12-27 23:43 traver 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Resource Acquisition Is Initialization cppreference 定义 RAII is a c++ programming technique which binds the life cycle of a resource that must be acqui 阅读全文
posted @ 2021-12-09 11:02 traver 阅读(58) 评论(0) 推荐(0) 编辑
摘要: heap sort 参考链接 满二叉树性质: parent=(i-1)/2,son_left=i*2+1,son_right=i*2+2 建堆 首先对数组建立大顶堆:父节点一定大于子节点 对每一个非叶节点递归进行比较(堆化) 最后一个非叶节点 结论:最后一个叶节点的父节点 证明:假设最后一个叶节点a 阅读全文
posted @ 2021-12-08 23:20 traver 阅读(25) 评论(0) 推荐(0) 编辑
摘要: Longest Palindromic Substring leetcode 5 问题描述 In computer science, the longest palindromic substring or longest symmetric factor problem is the proble 阅读全文
posted @ 2021-11-20 22:15 traver 阅读(22) 评论(0) 推荐(0) 编辑
摘要: Topological sort leetcode 210 问题描述 首先判断有向图里有无环,有环则没有拓扑排序 官方定义: a topological sort or topological ordering of a directed graph is a linear ordering of 阅读全文
posted @ 2021-11-18 22:45 traver 阅读(38) 评论(0) 推荐(0) 编辑
摘要: leetcode 124. Binary Tree Maximum Path Sum leetcode 124 题目描述 给定一个二叉树,返回最大路径和 思路 递归,返回以自身节点连接上左右任一branch或者单独自身,作为最大子路径返回。 同时,将自身看作是root,结合自己的左右branch,更 阅读全文
posted @ 2021-11-18 22:44 traver 阅读(19) 评论(0) 推荐(0) 编辑
摘要: leetcode 678. Valid Parenthesis String leetcode 678 题目描述 字符'*'可当作是'('或')'或空字符,判断一个括号字符串是否匹配 思路 cmax,cmin记录当前左括号的取值范围为[cmin,cmax],'*'当作'(',则cmax+=1,'*' 阅读全文
posted @ 2021-11-18 22:44 traver 阅读(24) 评论(0) 推荐(0) 编辑