Linux 0.11主要包含文件管理和进程管理两个部分。进程管理包括内存管理、进程管理、进程间通信模块。文件管理包含磁盘文件系统,打开文件内存数据。磁盘文件系统包括空闲磁盘块管理,文件数据块的管理,文件元数据的管理,树形结构目录。打开文件内存数据包括文件描述符表、file文件表、inode节点表。
总结
Linux 0.11主要包含文件管理和进程管理两个部分。进程管理包括内存管理、进程管理、进程间通信模块。文件管理包含磁盘文件系统,打开文件内存数据。磁盘文件系统包括空闲磁盘块管理,文件数据块的管理,文件元数据的管理,树形结构目录。打开文件内存数据包括文件描述符表、file文件表、inode节点表。
中断过程
- 每个进程都有一个用户堆栈和一个进程堆栈。中断调用导致用户堆栈切换到内核堆栈,而中断返回导致内核堆栈切换到用户堆栈。
[En]
each process has a user stack and a process stack. The interrupt call causes the user stack to switch to the kernel stack, and the interrupt return causes the kernel stack to switch to the user stack.*
- INT指令中调调用时,用户态运行状态被保存到内核栈中
- IRET指令中断返回时,恢复用户态运行状态信息,包括用户栈地址信息
- 系统调用基于int 80软中断实现,80中断程序根据系统调用号调用相应的函数,如sys_read、sys_write
- 时间片轮换进程调度基于时钟中断。当进程时间片用完时,时钟中断发生,中断程序运行调度程序。
[En]
time slice rotation process scheduling is based on clock interrupts. When the process time slices are used up, the clock interrupt occurs, and the interrupt program runs the scheduler instead.*
- 进程调度的本质是在运行状态之间切换。选中的程序会将选中进程的运行状态信息复制到硬件寄存器中,并运行选中的程序。
[En]
the essence of process scheduling is to switch between running states. The selected program will copy the running status information of the selected process into the hardware register and run the selected program.*
内存管理
- 分页内存管理包括空闲块的管理、进程基于页表管理已分配的物理内存;分段内存管理通过段表(LDT)管理分段内存信息。
- 地址翻译经过段号:偏移—>线性地址—>物理地址的二次转换过程,设置好段表(LDTR)和页表(PTBR)信息后,内存管理单元(MMU)自动完成地址翻译过程。
文件管理
磁盘数据结构
- 可通过链表、位图、组链接等方式管理磁盘空闲块。
[En]
disk free blocks can be managed through linked lists, bitmaps, group linking, etc.*
- 管理文件数据块,通过类似于页表的结构维护文件逻辑块与磁盘物理块之间的映射
[En]
Management of file data blocks to maintain the mapping between file logical blocks and disk physical blocks through a structure similar to page tables*
- 磁盘文件的管理,通过inode数组维护所有文件信息,inode记录对应的文件信息
- 树形目录结构,目录数据文件包含子文件名—>子文件inode号的映射关系,从而形成树形目录结构。
打开文件的内存数据结构
- inode表,记录文件的inode数据,用磁盘上文件inode数据基本一致
- file表,记录打开文件的信息,维护进程对文件的操作状态,如读写偏移
- 文件描述符表,记录进程打开的文件集合。表项是文件表的下标索引。
[En]
File descriptor table, which records the collection of files opened by the process. The table entry is the subscript index of the file table.*
- fork后父子进程文件描述符表相同;不同进程打开同一文件,具有不同的file数据,即拥有不同的读写偏移。
高速缓冲
- 使用空闲链表管理空闲缓冲区
[En]
Management of free buffers, using free linked lists*
- 管理已分配的缓冲区。为了加快访问速度,使用了哈希表。散列函数的输入是设备号和磁盘块号。
[En]
Management of allocated buffers. In order to speed up access, a hash table is used. The input of the hash function is the device number and disk block number.*
- 脏缓冲块数据的写盘,缓冲块需要重新缓存其它磁盘块的数据时,对于旧的数据,如果具有脏数据(dirt位为1),则写入磁盘
块驱动程序
- 通过设备表管理块设备,记录设备的请求队列地址,处理请求函数地址。
[En]
manage block devices through the device table, record the request queue address of the device, and process the request function address.*
- 请求队列维护对磁盘的所有读写请求,所有读写请求都放在请求队列中
[En]
the request queue maintains all read and write requests to the disk, and all read and write requests are placed in the request queue*
- 设备中断处理程序,不断处理请求队列中的读写请求
[En]
device interrupt handler, constantly processing read and write requests in the request queue*
Original: https://www.cnblogs.com/lazyfiish/p/16092507.html
Author: LazyFish
Title: Linux 0.11源码阅读笔记-总结
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/523896/
转载文章受原作者版权保护。转载请注明原作者出处!