摘要: 概述 hash table 和 B+ Tree 可以说是数据库中最重要的两种数据结构。DBMS 的 page table 或者 page directory 都可以说用到了 hash table。 hash function sha-256 的计算成本过高(我们无需关心它在密码学方面的特性),xxh 阅读全文
posted @ 2023-09-04 21:50 zwyyy456 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 概述 本节主要讨论数据在内存和硬盘之间的移动的管理,可以分为两个部分,空间控制(Spatial Control)和时间控制(Temporal Control)。 spatial control 决定将 pages 写到磁盘的哪个位置,使得常常在一起使用的 pages 能离得比较近,从而提高 I/O 阅读全文
posted @ 2023-09-04 21:50 zwyyy456 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 问题描述 31. 下一个排列 (Medium) 整数数组的一个 排列 就是将其所有成员以序列或线性顺序排列。 例如, arr = [1,2,3] ,以下这些都可以视作 arr 的排列: [1,2,3]、 [1,3,2]、 [3,1,2]、 [2 ,3,1] 。 整数数组的 下一个排列 是指其整数的下 阅读全文
posted @ 2023-09-04 21:50 zwyyy456 阅读(6) 评论(0) 推荐(0) 编辑
摘要: Large files 这个作业需要我们将 xv6 的最大文件大小从 12 + 256 Bytes 修改为 11 + 256 + 256 * 256 Bytes。 为了达成这个目标,我们需要使用二级索引块,对 inode 的 addrs 字段,首先将 NDIRECT 从 $12$ 修改为 $11$, 阅读全文
posted @ 2023-08-02 19:08 zwyyy456 阅读(27) 评论(0) 推荐(0) 编辑
摘要: Memory allocator 这一题很简单,主要任务,就是为每个 cpu 维护一个空闲物理内存的链表 freelist,xv6 默认使用的结构体 kmem,其中包含一个 freelist 供所有的 cpu 使用。我们要做的,就是把 freelist 修改成 freelist 的数组,即 stru 阅读全文
posted @ 2023-07-30 21:02 zwyyy456 阅读(22) 评论(0) 推荐(0) 编辑
摘要: Logging layer file system 设计的一大重要问题就是 crash recovery。这是因为文件系统操作往往涉及向磁盘多次写入,而几次写入之后的 crash 可能导致磁盘上的文件系统处于一个不一致的状态。 For example, suppose a crash occurs 阅读全文
posted @ 2023-07-30 21:02 zwyyy456 阅读(15) 评论(0) 推荐(0) 编辑
摘要: Overview 文件系统的设计目标就是组织和存储数据,文件系统一个比较重要功能是持久化,即重启之后,数据不会丢失。xv6 通过把数据存储在 virtio disk 上来实现持久化。 文件系统设计的几大挑战: The file system needs on-disk data structures 阅读全文
posted @ 2023-07-30 21:02 zwyyy456 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 问题描述 335. 路径交叉 (Hard) 给你一个整数数组 distance。 从 X-Y 平面上的点 (0,0) 开始,先向北移动 distance[0] 米,然后向西移动 distance[1] 米,向南 移动 distance[2] 米,向东移动 distance[3] 米,持续移动。也就是 阅读全文
posted @ 2023-07-28 16:56 zwyyy456 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Description 335. Self Crossing (Hard) You are given an array of integers distance. You start at the point (0, 0) on an X-Y plane, and you move distanc 阅读全文
posted @ 2023-07-28 16:56 zwyyy456 阅读(15) 评论(0) 推荐(0) 编辑
摘要: Description 2050. Parallel Courses III (Hard) You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also g 阅读全文
posted @ 2023-07-28 16:55 zwyyy456 阅读(3) 评论(0) 推荐(0) 编辑