Understanding the Linux Kernel 读书笔记 -Timing Measurements

We can distinguish two main kinds of timing measurement that must be performed by the Linux kernel:

  • Keeping the current time and date so they can be returned to user programs through the time(), ftime(), and gettimeofday() APIs and used by the kernel itself as timestamps for files and network packets
  • Maintaining timers—mechanisms that are able to notify the kernel or a user program that a certain interval of time has elapsed

Understanding the Linux Kernel 读书笔记 -Kernel Synchronization

You could think of the kernel as a server that answers requests; these requests can come either from a process running on a CPU or an external device issuing an interrupt request. We make this analogy to underscore that parts of the kernel are not run serially, but in an interleaved way. Thus, they can give rise to race conditions, which must be controlled through proper synchronization techniques.

深入理解 Linux 的 RCU 机制

1 Introduction

Read-copy update (RCU) is a synchronization mechanism. RCU achieves scalability improvements by allowing reads to occur concurrently with updates. In contrast with conventional locking primitives that ensure mutual exclusion among concurrent threads regardless of whether they be readers or updaters, or with reader-writer locks that allow concurrent reads but not in the presence of updates, RCU supports concurrency between a single updater and multiple readers.

Fix-Mapped Linear Addresses

引言

fixmap是一段固定地址映射,kernel预留的一段虚拟地址空间,虚拟地址是在编译的时候确定。fixmap可以用来做什么?kernel启动初期,由于此时的kernel已经运行在虚拟地址上。因此我们访问具体的物理地址是不行的,必须建立虚拟地址和物理地址的映射,然后通过虚拟地址访问才可以。例如:dtb中包含bootloader传递过来的内存信息,我们需要解析dtb,但是我们得到的是dtb的物理地址。因此访问之前必须创建映射,创建映射又需要内存系统。但是由于所有的内存管理子系统还没有ready,因此我们不能使用ioremap接口创建映射,为此kernel提出fixmap的解决方案。

内核页表和进程页表

本文转载自:chinaunix

初学内核时,经常被“内核页表”和“进程页表”搞晕,不知道这到底是个啥东东,跟我们平时理解的页表有和关系。

  • 内核页表:即书上说的主内核页表,在内核中其实就是一段内存,存放在主内核页全局目录init_mm.pgd(swapper_pg_dir)中,硬件并不直接使用。

  • 进程页表:每个进程自己的页表,放在进程自身的页目录task_struct.pgd中。

Understanding the Linux Kernel 读书笔记 -Process

Processes, Lightweight Processes, and Threads

A process is an instance of a program in execution. You might think of it as the collection of data structures that fully describes how far the execution of the program has progressed. The purpose of a process is to act as an entity to which system resources (CPU time, memory, etc.) are allocated.

分段机制解析

硬件中的分段

1.1 段选择符和段寄存器

分段是一种朴素的内存管理机制,它将内存划分成以起始地址(Base)和长度(Limit)描述的块,这些内存块就被称为“段”。