Virtual storage knowledge points for Linux processes

Source: Internet
Author: User
Tags data structures garbage collection

Using LibreOffice to draw a table is really a bit of a pain in the egg, inefficient. deep understanding of computer system-> virtual memory Kernel Virtual Storage

The operating system process time is user state and kernel state. In virtual storage, process virtual memory occupies a large part of the space, and kernel virtual memory occupies a small space. process-related data structures

Each process is not the same. So not every process has the same kernel virtual memory, which has different parts of the process.

This area is associated with:
1.task_struct
(1) State: Process Status
(2) Thread_info: Process information and kernel stack
(3) Run_list,array: for process scheduling
(4) MM: Process address space
(5) PID: Process ID
(6) Group_info: Group Management
(7) User: Users Management
(8) FS: working directory, root directory
(9) Signal: signal information
(a) Sighand: Signal Processing
(11) Program counter
Wait a minute....
one of the most important when mm, is mm_struct

2.mm_struct
(1) PGD: Point to First Level page table base Address
(2) Mmap: Point to a vm_area_struct (area structure) list, each vm_area_struct describes a region (area) of the current virtual address space.
Wait a minute...
key mmap.

3.vm_area_struct
(1) Vm_end
(2) Vm_start
(3) Vm_prot: Read and Write permission
(4) Vm_flags: private or shared
(5) Vm_next: Point to the next regional structure in the list physical memory and kernel code and data

Related knowledge points: When to change from user state to kernel state. Process Virtual Memory Memory map area for shared libraries

Linux initializes the contents of this virtual memory by associating a virtual storage area with an object on a disk called a memory map.

If the system's executable depends on the shared library, it is mapped to that zone. such as printf functions and so on ... data is not initialized. BSS, initialized data and program files. Text

These three sections are called BSS segments, data segments, and code segments.
BSS segment: global and static variables uninitialized or initial =0.
Data segment: global and static variables initialized with initial!=0.
Code snippet: Executable code, string literal, read-only variable.
Note: Local variables are on the stack. Stacks and Heaps Stack

1. Automatic allocation of releases by the compiler.

2. The purpose of the stack in this function
Put local variables into stack to save

3. The purpose of the stack when calling functions
(1) storing the parameter values of the invoked function
(2) return address into stack
(3) The Non-static local variables used by the called function and other temporary variables that the compiler automatically generates.
(4) Save the context, save the function call before and after the need to remain unchanged registers.

4. When the function is called, the data into the stack order
(1) The parameters of the called function (C compiler, parameters from right to left into the stack)
(2) Return address
(3) The old%EBP address for restoration.
(4) Saved registers
(5) Local variables and other data for the new function.

Note: Static variables are not included in the stack. After the function is finished, restore the scene. Detailed << in-depth understanding of computer systems >> Section 3.7.

5. With the data structure of the stack characteristics of the same, LIFO first out. See figure, when the stack, to the low address extension. Heap

1. The programmer is generally assigned to release.
Related knowledge points also include garbage collection.

2. When programmers use New,delete (dynamically assigning instructions), they generate data in the heap area of the process.

3. Heap of knowledge points, mainly when dynamic memory allocation of knowledge points, including
(1) Allocator type: Implicit distributor and explicit distributor.
(2) Alignment problem
(3) Fragmentation problem
(4) Implement allocator: How to record the free block, how to place, how to split, how to merge
(5) Implicit free list
(6) Explicit free list
(7) Separation of free linked list
(8) Garbage collection

all the above content source << deep Understanding computer system >> Here is just a small summary, can be said to be a small note. Please read the book for more information.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.