I. Linux memory system
- Physical and virtual memory
- The Linux kernel can only directly map the first GB of physical memory (896M, as it also takes into account reserved space). The memory on this is called Zone_normal, and this part of the space must be mapped to the bottom 1GB.
- Virtual Memory addressing Layouts
Virtual addressing layout for 32-bit and 64-bit architecture Linux systems:
On a 32-bit architecture, the maximum address space that a single process can take advantage of is 4GB, which is limited by the 32-bit virtual memory mapping and 64-bit architecture because there is no memory limit, and each process can potentially use a large address space.
- Virtual Memory Manager
- Page frame allocation: A page is a contiguous set of linear addresses in physical memory or virtual memory, the Linux kernel processes memory in pages, and the page size is typically 4KB.
- Partner system: The Linux kernel maintains free pages using a mechanism called the partner system (Buddy Systems), the partner system maintains the free pages, and attempts to assign pages to the process that sent the page request
- The partner system allocates memory pages:
- Page Frame Reclamation: When a process requests a specified number of memory pages without available memory pages, the kernel attempts to release a specific memory page for use by the new request, which is called memory reclamation. KSWAPD Kernel threads and try_to_free_page () kernel functions are responsible for page recycling.
KSWAPD usually sleeps in the task interruptible state, which is awakened by the partner system when the free page in a region falls below the threshold. There are two main uses of the page: page Cahe and process address space.
- Swap: is to ensure that the operating system can allocate more than the physical memory size of space, but Linux uses swap space is more efficient way.
Two. linux file system
- Virtual file system
A virtual file system (VFS) is an abstract interface layer between user processes and various file systems, and VFS provides a common object model for accessing file system objects (for example, I-node, file objects, page caches,), and methods
- Log
The log system solves the problem of fsck working to use the file system before he writes the data to be modified to a place called the journal area.
- Ext2
Ext2 is a simple and fast file system with no log functionality.
EXT2 file system data structure, the file system is started by a boot sector (boot sector) followed by blocks (block groups).
The kernel first searches for the i-node of the file, and when it receives a request from the process to open the/var/log/messages file, the kernel parses the file path and then searches/(the root directory) for the entry, the kernel will find the/var directory i-node, and then look at the/var directory until you find the/var The I-node of the/log/messages file. Once the kernel finds the file's I-node, it tries to access the real user data block.
- Ext3
EXT3 has: availability, data integrity, speed, flexibility
- Log mode
Log (journal) by logging file data and meta data
Ordered (ordered) only metadata is recorded in this mode
Write-Back (writeback) This log option provides the fastest data access capability
- Reiserfs
ReiserFS is a fast log file system with optimized disk space utilization and fast crash recovery capabilities
- Log file system
The logfile system (Journal file SYSTEM,JFS) is a full 64-bit file system that can support very large files and partitions.
- Xfs
Support for oversized files and partitions
Linux memory system and file system