java background surface _ operating system

One, introduce the linux memory model

There are 3 memory models supported in the linux kernel, namely flat memory model , Discontiguous memory model and sparse memory model . The so-called memory model is actually the distribution of its physical memory from the perspective of the cpu, and what method is used to manage the physical memory in the linux kernel.

1 flat memory model

If from the perspective of any processor in the system, when it accesses physical memory, the physical address space is a continuous address space without holes, then the memory model of this computer system is flat memory.

2 discontiguous memory model

If the cpu has some holes in its address space when accessing physical memory, it is not continuous, then the memory model of this computer system is discontiguous memory.

3 sparse memory model

Sparse memory model was born to solve memory hotplug.

Second, the page table

The page table is a special data structure that is placed in the page table area of ​​the system space to store the correspondence between logical pages and physical page frames. Each process has its own page table.

The role of the page table:

Realize the address mapping from page number to physical block number.

The process of converting a logical address into a physical address is: use the page number p to retrieve the page table, get the physical block number of the page from the page table, and load it into the physical address register . At the same time, the page address d is directly sent to the block address field of the physical address register . In this way, the content in the physical address register is the actual memory access address that is spliced ​​by the two, thus completing the conversion from the logical address to the physical address.

3. Some data is on the disk and is to be sent to the network. What are the processes?

1. In the Linux operating system, the JVM sends the sendfile command to the kernel space in the user space, and changes to the kernel mode. The kernel reads data from the hardware to the kernel buffer, which produces the first data copy ;
2. When the data is prepared in the kernel space, the kernel directly copies the data to the socket buffer, which produces a second data copy , and switches from the kernel mode to the user mode;
3. When the data preparation of the socket buffer is completed, Copy the data to the protocol engine and send it to the network, which produces the third data copy ;
 

 

Guess you like

Origin blog.csdn.net/orzMrXu/article/details/102533143