计算机内存系统、文件系统、ext2文件系统

WARNING: This article may be obsolete
This post was published in 2021-10-21. Obviously, expired content is less useful to users if it has already pasted its expiration date.
This article is categorized as "Garbage" . It should NEVER be appeared in your search engine's results.


如无明显声明,本文所涉及的inode/bitmap/ ... 等概念都默认归属于ext2文件系统。


一个很好的总结:

🔗 [请问CPU,内核,寄存器,缓存,RAM,ROM的作用和他们之间的联系? - 知乎] https://www.zhihu.com/question/24565362

上面的知乎链接中还可以复习一下DRAM和SRAM的对比


Internal and External fragmentation

🔗 [Difference between Internal and External fragmentation - GeeksforGeeks] https://www.geeksforgeeks.org/difference-between-internal-and-external-fragmentation/


寄存器

🔗 [記憶體階層 - 维基百科,自由的百科全书] https://zh.wikipedia.org/wiki/記憶體階層

🔗 [寄存器 - 维基百科,自由的百科全书] https://zh.wikipedia.org/zh/寄存器#:~:text=寄存器(Register)是中央處理,加速電腦程式的執行。

(寄存器在这里写为暂存器)

(下面有一张图来自这个博客,讲述了为什么RAM比寄存器慢)🔗 [为什么寄存器比内存快? - 阮一峰的网络日志] https://www.ruanyifeng.com/blog/2013/10/register.html


逻辑地址,物理地址,虚拟地址,内存分页


🔗 [物理地址、虚拟地址(线性地址)、逻辑地址以及MMU的知识_macrossdzh的博客-CSDN博客线性地址] https://blog.csdn.net/macrossdzh/article/details/5954763

🔗 [逻辑地址、物理地址、虚拟地址_牛客博客] https://blog.nowcoder.net/n/ff17a69af02b464aa675f13a95a6d28c?from=nowcoder_improve


为什么逻辑地址看起来和虚拟地址差不多?它们有什么区别?

https://www.zhihu.com/question/29918252

逻辑地址和物理地址的转换是「操作系统」决定的、CPU处理的;尽管上述链接使用了“程序编译”来讲解,但编译器并不会决定逻辑地址和物理地址的转换。

https://www.ruanyifeng.com/blog/2013/10/register.html

page和frame的区别

🔗 [Page (computer memory) - Wikipedia] https://en.wikipedia.org/wiki/Page_(computer_memory)#:~:text=Similarly%2C a page frame is,to as paging or swapping.


🔗 [没有内存条的情况下,能不能用硬盘代替内存条运行系统? - 知乎] https://www.zhihu.com/question/339181897


cpu mmu | 内存管理单元

也就是Memory management unit

🔗 [内存管理单元 - 维基百科,自由的百科全书] https://zh.wikipedia.org/wiki/内存管理单元


mmap

🔗 [mmap详解] https://nieyong.github.io/wiki_cpu/mmap详解.html


分页表 | page table | PTE

🔗 [分頁表 - 维基百科,自由的百科全书] https://zh.wikipedia.org/wiki/分頁表


多级分页表


page把进程分割为多个页面
页面把进程分割为多个页面
页框page frame物理内存上的一块一块
页表page table操作系统虚拟内存到物理内存的映射表
页码用于定位虚拟内存上的「页」/ page
页内偏移量用于定位虚拟内存上某一「页」内部的offset
页框偏移量用于定位物理内存上某一「页框」内部的offset

「页框」和「页面」的关系

🔗 [操作系统学习笔记-12:内存分配(二):非连续分配 - 云+社区 - 腾讯云] https://cloud.tencent.com/developer/article/1624629


先考虑1级页表结构:

🔗 [虚拟内存机制,页&页框&页表 物理地内存和虚拟内存的联系_Peanutty的博客-CSDN博客虚拟内存页] https://blog.csdn.net/hhb442/article/details/109478334


再考虑两级页表结构:

(这篇文章非常重要,里面有2个重要例题)🔗 [两级页表 | snowFlakeXue] https://snowflakexue.github.io/2019/11/06/两级页表/



page fault | 页缺失

🔗 [页缺失 - 维基百科,自由的百科全书] https://zh.wikipedia.org/wiki/页缺失#:~:text=页缺失(英語:Page fault,是操作系统的一部分。


系统颠簸 | Thrashing

首先要了解各种置换算法:🔗 [页面置换算法 - dpatrickx's wiki] https://dpatrickx.github.io/wiki/os/page/#3

🔗 [9.6 系统颠簸(thrashing) | OperatingSystem-note] https://t0ugh.github.io/OperatingSystem-note/ch9-虚拟内存/6-系统颠簸.html


TLB

对内存分页表的缓存(读取分页表的速度很慢,读取TLB缓存的速度很快):

🔗 [轉譯後備緩衝區 - 维基百科,自由的百科全书] https://zh.wikipedia.org/wiki/轉譯後備緩衝區


LRU内存淘汰算法

🔗 [LRU cache原理和简单实现 - 博海文思] https://skyhigh233.com/blog/2016/10/07/lru-cache/


linux magic number

🔗 [Magic Number魔数是什么_2er013的博客-CSDN博客_magic number] https://blog.csdn.net/abcdyzhang/article/details/56331492

🔗 [魔数是什么? - 简书] https://www.jianshu.com/p/76e79a12eabf


linux soft link(symbolic link)和hard link (physical link)

假设有一个文件a.txt,为它创建了a_soft.txt和a_hard.txt;

使用rm删除a.txt以后,a_soft.txt会自动消失,而a_hard.txt不仅存在,还能正常读取文件内容。


文件系统的挂载

在linux环境下,如果把一个文件系统挂载到了一个「原本存在,且里面存放了一些文件」的目录上,那么这个目录下的文件会被删除吗?

不会,这些文件只是暂时(在挂载的时候)被隐藏了;当文件系统卸载后这些文件又回重新回来。

🔗 [tmp - What happens when you 'mount over' an existing folder with contents? - Unix & Linux Stack Exchange] https://unix.stackexchange.com/questions/198542/what-happens-when-you-mount-over-an-existing-folder-with-contents


berkeley fast file system

基本上可以认为是UFS文件系统,见:🔗 [Unix文件系统 - 维基百科,自由的百科全书] https://zh.wikipedia.org/zh-hans/Unix文件系统

诞生时间:

FFS:上世纪80年代

ext2:上世纪90年代

见:🔗 [Berkeley Fast File System | F叔的学习笔记] https://flaneur2020.github.io/2012/08/27/ffs-notes/


🔗 [filesystems - Relation between "Block Size"and "Upper Limits" in ext2 - Unix & Linux Stack Exchange] https://unix.stackexchange.com/questions/105102/relation-between-block-sizeand-upper-limits-in-ext2

🔗 [inode pointer structure - Wikipedia] https://en.wikipedia.org/wiki/Inode_pointer_structure#/media/File:Ext2-inode.svg


bitmap

https://unix.stackexchange.com/questions/105102/relation-between-block-sizeand-upper-limits-in-ext2

计算方法可以参考:🔗 [文件系统的原理 - 知乎] https://zhuanlan.zhihu.com/p/106459445


GDT - group descriptor table - 块组描述符表

为什么GDT这样看起来简单的表会占用不止一个block?

因为要复制多份,防止意外损坏带来的整个Group不可用的问题。如下图所示,ext2文件系统下:只有第一个GDT是实际使用的。

http://www.science.unitn.it/~fiorella/guidelinux/tlk/node98.html

🔗 [2. ext2文件系统] https://akaedu.github.io/book/ch29s02.html


进程间通信 | IPC

🔗 [张三同学没答好「进程间通信」,被面试官挂了…. - 知乎] https://zhuanlan.zhihu.com/p/165224175

主要需要看「信号量」相关的部分


父子进程

🔗 [操作系统---(15)父进程与子进程_Code_F1的博客-CSDN博客父进程和子进程] https://blog.csdn.net/qq_43101637/article/details/105079717


PC | program counter | 程序计数器

🔗 [程序计数器是什么(PC)_李兆龙的博客的博客-CSDN博客程序计数器pc的功能] https://blog.csdn.net/weixin_43705457/article/details/99750711


context switch和interrupt的比较

🔗 [Context Switching and Interrupt - 南寨小子] https://kangxiaoning.github.io/post/2021/06/context-switching-and-interrupt/


用户态和内核态

🔗 [怎样去理解Linux用户态和内核态? - 知乎] https://zhuanlan.zhihu.com/p/69554144



 Last Modified in 2022-06-28 

Leave a Comment Anonymous comment is allowed / 允许匿名评论