+};哈工大操作系统实验
实验入口
主要参考文章
lseek()函数:用于移动打开文件的指针
linux系统调用之write源码解析(基于linux0.11)
get_fs_bytes解析
VIM与系统剪贴板的复制粘贴
操作系统实验六 信号量的实现和应用(哈工大李治军)
哈工大操作系统实验6 信号量的实现 pc.c 编译时报错 对‘sem_open‘未定义的引用
Linux 文件编程 open函数
哈工大-操作系统-HitOSlab-李治军-实验5-信号量的实现和应用地址映射与共享
diff --git "a/2022/10/16/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2321\343\200\220Collection\351\203\250\345\210\206\343\200\221/index.html" "b/2022/10/16/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2321\343\200\220Collection\351\203\250\345\210\206\343\200\221/index.html" index 6a466f7e..b4df034b 100644 --- "a/2022/10/16/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2321\343\200\220Collection\351\203\250\345\210\206\343\200\221/index.html" +++ "b/2022/10/16/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2321\343\200\220Collection\351\203\250\345\210\206\343\200\221/index.html" @@ -48,7 +48,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};阅读JDK容器部分源码的心得体会1【Collection部分】
+};阅读JDK容器部分源码的心得体会1【Collection部分】
idea 替换注释正则表达式
/\*{1,2}[\s\S]*?\*/
typora 替换图片asset
diff --git "a/2022/10/22/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2322\343\200\220Map\351\203\250\345\210\206\343\200\221/index.html" "b/2022/10/22/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2322\343\200\220Map\351\203\250\345\210\206\343\200\221/index.html" index 0127707b..5144a550 100644 --- "a/2022/10/22/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2322\343\200\220Map\351\203\250\345\210\206\343\200\221/index.html" +++ "b/2022/10/22/\351\230\205\350\257\273JDK\345\256\271\345\231\250\351\203\250\345\210\206\346\272\220\347\240\201\347\232\204\345\277\203\345\276\227\344\275\223\344\274\2322\343\200\220Map\351\203\250\345\210\206\343\200\221/index.html" @@ -43,7 +43,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};
\!\[.*\]\(D:\\aWorkStorage\\hexo\\blog\\source\\_posts\\阅读JDK容器部分源码的心得体会1【Collection部分】\\(.*)\.png\)
,阅读JDK容器部分源码的心得体会2【Map部分】
+};阅读JDK容器部分源码的心得体会2【Map部分】
idea 替换注释正则表达式
/\*{1,2}[\s\S]*?\*/
typora 替换图片asset
diff --git "a/2022/11/06/Java\345\271\266\345\217\221\347\274\226\347\250\213\345\256\236\346\210\230/index.html" "b/2022/11/06/Java\345\271\266\345\217\221\347\274\226\347\250\213\345\256\236\346\210\230/index.html" index 602deacf..ce3cd971 100644 --- "a/2022/11/06/Java\345\271\266\345\217\221\347\274\226\347\250\213\345\256\236\346\210\230/index.html" +++ "b/2022/11/06/Java\345\271\266\345\217\221\347\274\226\347\250\213\345\256\236\346\210\230/index.html" @@ -382,7 +382,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};
\!\[.*\]\(D:\\aWorkStorage\\hexo\\blog\\source\\_posts\\阅读JDK容器部分源码的心得体会2【Map部分】\\(.*)\.png\)
,Java并发编程实战
+};Java并发编程实战
idea 替换注释正则表达式
/\*{1,2}[\s\S]*?\*/
第一章 简介
线程的作用
diff --git a/2022/12/21/JavaWeb/index.html b/2022/12/21/JavaWeb/index.html index 9118fb07..0cbab8c7 100644 --- a/2022/12/21/JavaWeb/index.html +++ b/2022/12/21/JavaWeb/index.html @@ -152,7 +152,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};
JavaWeb
第一部分 Java基础
JUnit单元测试
JUnit是白盒测试。
+};JavaWeb
第一部分 Java基础
JUnit单元测试
JUnit是白盒测试。
简要使用步骤
定义测试类
包含各种测试用例。
一般放在包名xxx.xxx.xx.test里,类名为“被测试类名Test”。
定义测试方法
测试方法可以独立运行。
diff --git a/2023/01/10/xv6$chap1/index.html b/2023/01/10/xv6$chap1/index.html index 36f8ae3a..f3991270 100644 --- a/2023/01/10/xv6$chap1/index.html +++ b/2023/01/10/xv6$chap1/index.html @@ -48,7 +48,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};Operating system interface
Operating system interface
本节大概是在讲操作系统的接口,系统调用占了很大一部分。
+};Operating system interface
Operating system interface
本节大概是在讲操作系统的接口,系统调用占了很大一部分。
diff --git a/2023/01/10/xv6$chap2/index.html b/2023/01/10/xv6$chap2/index.html index 7f2bb7eb..1f5a3265 100644 --- a/2023/01/10/xv6$chap2/index.html +++ b/2023/01/10/xv6$chap2/index.html @@ -43,7 +43,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -}; Operating system oganization
Operating system oganization
+};Operating system oganization
Operating system oganization
Before you start coding, read Chapter 2 of the xv6 book, and Sections 4.3 and 4.4 of Chapter 4, and related source files:
- The user-space code for systems calls is in
diff --git a/2023/01/10/xv6$chap3/index.html b/2023/01/10/xv6$chap3/index.html index 5d5df23b..cfa1243d 100644 --- a/2023/01/10/xv6$chap3/index.html +++ b/2023/01/10/xv6$chap3/index.html @@ -53,7 +53,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};user/user.h
anduser/usys.pl
.Page tables
Page tables
Paging hardware
为什么需要页表
将主存储器以及各种外设接口卡里面内置的存储器连接起来,就形成了内存地址空间。内存地址空间中的地址是真实的物理地址。RISC-V架构的指令使用的地址是虚拟地址。为了通过指令中的虚拟地址访问到真实的物理内存,需要进行从虚拟地址到物理地址的转换。从虚拟地址到物理地址的转换,就需要通过页表来实现。
+};Page tables
Page tables
Paging hardware
为什么需要页表
将主存储器以及各种外设接口卡里面内置的存储器连接起来,就形成了内存地址空间。内存地址空间中的地址是真实的物理地址。RISC-V架构的指令使用的地址是虚拟地址。为了通过指令中的虚拟地址访问到真实的物理内存,需要进行从虚拟地址到物理地址的转换。从虚拟地址到物理地址的转换,就需要通过页表来实现。
页表如何运作
在RISC-V指令集中,当我们需要开启页表服务时,我们需要将我们预先配置好的页表首地址放入
satp
寄存器中。从此之后, 计算机硬件 将把访存的地址 均视为虚拟地址 ,都需要通过硬件查询页表,将其 翻译成为物理地址 ,然后将其作为地址发送给内存进行访存。xv6采用的指令集标准为RISC-V标准,其中页表的标准为SV39标准,也就是虚拟地址最多为39位。
虚实地址翻译流程:
diff --git a/2023/01/10/xv6$chap4/index.html b/2023/01/10/xv6$chap4/index.html index 525f1c2c..7da90cb1 100644 --- a/2023/01/10/xv6$chap4/index.html +++ b/2023/01/10/xv6$chap4/index.html @@ -58,7 +58,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};Traps and system calls
Traps and system calls
traps=系统调用+异常+中断。本章着重讲traps概述以及traps中的系统调用。
+};Traps and system calls
Traps and system calls
traps=系统调用+异常+中断。本章着重讲traps概述以及traps中的系统调用。
对trap的处理包含四个部分:硬件处理、中断向量、trap handler、对应的处理函数
RISC-V trap machinery
diff --git a/2023/01/10/xv6$chap5/index.html b/2023/01/10/xv6$chap5/index.html index 4230ff1c..84c7cc26 100644 --- a/2023/01/10/xv6$chap5/index.html +++ b/2023/01/10/xv6$chap5/index.html @@ -39,7 +39,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};
Interrupts and device drivers
Interrupts and device drivers
+};Interrupts and device drivers
Interrupts and device drivers
A driver is the code in an operating system that manages a particular device:
- configures the device hardware
diff --git a/2023/01/10/xv6$chap6/index.html b/2023/01/10/xv6$chap6/index.html index 8a89251b..7e4fac8f 100644 --- a/2023/01/10/xv6$chap6/index.html +++ b/2023/01/10/xv6$chap6/index.html @@ -44,7 +44,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};Locking
Locking
很多概念在看Java并发的时候都学习过,这些重复的地方就不做赘述了。
+};Locking
Locking
很多概念在看Java并发的时候都学习过,这些重复的地方就不做赘述了。
Code: spinlock
一、spinlock 简介
diff --git a/2023/01/10/xv6$chap7/index.html b/2023/01/10/xv6$chap7/index.html index b96b19bd..6cf85cf3 100644 --- a/2023/01/10/xv6$chap7/index.html +++ b/2023/01/10/xv6$chap7/index.html @@ -44,7 +44,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};
自旋锁(spinlock):是指当一个线程在获取锁的时候,如果锁已经被其它线程获取,那么该线程将循环等待,不断尝试获取锁,直到获取到锁才会退出循环Scheduling
Scheduling
Code: Context switching
xv6中,每个CPU中的scheduler都有一个专用的线程。这里线程的概念是,有自己的栈,有自己的寄存器状态。
+};Scheduling
Scheduling
Code: Context switching
xv6中,每个CPU中的scheduler都有一个专用的线程。这里线程的概念是,有自己的栈,有自己的寄存器状态。
当发生时钟中断时,当前进程调用yield,yield再通过swtch切换到scheduler线程。scheduler线程会通过swtch跳转到另外一个进程去执行。当另外一个进程发生时钟中断,又会通过yield回到scheduler,scheduler再调度原进程继续执行,如此周而复始。
Linux的调度原理也差不多类似这样。每个CPU都有一个调度类为SCHED_CLASS_IDLE的IDLE进程,IDLE进程体大概就是间歇不断地执行__schedule()函数,CPU空闲时就会不断执行IDLE线程。
diff --git a/2023/01/10/xv6$chap8/index.html b/2023/01/10/xv6$chap8/index.html index b018624e..6c6f814d 100644 --- a/2023/01/10/xv6$chap8/index.html +++ b/2023/01/10/xv6$chap8/index.html @@ -51,7 +51,7 @@ // Wait for 1 second before switching API hosts rotate: 1000, }, -};File system
File system
+};File system
File system
@@ -748,4 +748,4 @@来到指导书最高点!太美丽了xv6。哎呀那不文件系统吗(
这里是自底向上讲起的。之后可以看看hit网课的自顶向下。
fork
1
2
3
4
5
6
7
8
9
10
11
12 for(int i=0;i<NFILEMAP;i++){
np->filemaps[i].isused = p->filemaps[i].isused;
np->filemaps[i].va = p->filemaps[i].va;
np->filemaps[i].okva = p->filemaps[i].okva;
np->filemaps[i].file = p->filemaps[i].file;
np->filemaps[i].length = p->filemaps[i].length;
np->filemaps[i].flags = p->filemaps[i].flags;
np->filemaps[i].offset = p->filemaps[i].offset;
np->filemaps[i].prot = p->filemaps[i].prot;
if(np->filemaps[i].file)
filedup(np->filemaps[i].file);
}修改uvmcopy和uvmunmap
-
1
2
3
4
5
6
7
8
9 // in uvmunmap()
if((*pte & PTE_V) == 0){
*pte = 0;
continue;
}
// in uvmcopy()
if((*pte & PTE_V) == 0)
//panic("uvmcopy: page not present");
continue;I'm so cute. Please give me money.
- 本文链接:https://xiunianjun.github.io/2023/01/10/xv6$chap8/
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。