-
-
-
- 1. Three ways to load the program into memory
- Two, three ways of program linking
- 3. Covering technology
- Four, exchange technology
- 5. Continuous distribution management method
- Six, basic paging storage management
- Seven, two-level page table mechanism
- 8. Basic segmented storage management
- Nine, segment page storage management
- 10. Virtual storage technology
-
- Characteristics and disadvantages of traditional storage management methods
- Definition and characteristics of virtual storage
- Implementation of Virtual Storage Technology
- Basic page table and request page table
- Operation when a page fault is interrupted
- The difference between request paging and basic paging
- Points to note when requesting pagination
- 11. Page replacement algorithm
- 12. Page allocation strategy
- Thirteen, stack allocation
-
-
1. Three ways to load the program into memory
1. Absolute loading
2. Repositionable loading
3. Dynamic Relocation
The process from writing to running
Two, three ways of program linking
3. Covering technology
Four, exchange technology
5. Continuous distribution management method
1. Single continuous distribution (continuous)
2. Fixed partition allocation (continuous)
Partition description table
3. Dynamic partition allocation (continuous)
Data structure for storage
Partition allocation algorithm
- First fit algorithm: free partition according to address increasing order link, each from a low start address lookup , find the first free partition size to meet
- Best fit algorithm: free partition in accordance with the capacity increasing order links, order to find spare partition chain every time memory allocation
- The worst adaptation algorithm: free partition in accordance with the descending order of capacity link, find the spare partition chain sequence each time memory allocation
- Nearby adaptation algorithm: free partition according to address increasing order link, each time from the beginning of the end to find the last time to find the location , find the first free partition size to meet. You can skip as first fit algorithm small free partitions much lower address section. In the end, the remaining free partitions are relatively uniform .
Distribution and recycling of partitions : As long as the recycled partitions are adjacent to other free partitions, they need to be merged.
Six, basic paging storage management
Page, page: the part after the process is divided.
Page frame, page frame: the part after the memory space is divided.
Page table
Address translation
Example address conversion
Note: If the size of each page is 2 k B 2^k B2k B, use a binary number to represent the logical address, then the endkkThe k bit is the offset within the page, and the rest is the page number. If the page size happens to be2 22 integer powers, the page table need only recorda physical block numberandpage offsetsplicing to givethe physical address
Address conversion mechanism
base address conversion table means having a fast (TLB) of
Fast table: It is a high-speed cache with much faster access speed than memory (TLB is cache, not memory). It is used to store a copy of recently accessed page table entries , which can speed up address conversion. Corresponding to this, the page table in memory is called a slow table.
Note: Fast table can reduce the number of memory accesses, and access to fast table is faster than access to memory at the same time
After the introduction of fast tables, address conversion speeds up
Principle of locality
Seven, two-level page table mechanism
Problems with single-level page tables:
- The page table must be stored continuously, so when the page table is large, it needs to occupy a lot of continuous page frames
- There is no need to make the entire page table resident in memory, because the process may only need to access a few specific pages for a period of time
8. Basic segmented storage management
Segmented storage management address conversion mechanism
Comparison of paging and segmentation
Nine, segment page storage management
Paragraph address conversion mechanism
10. Virtual storage technology
Characteristics and disadvantages of traditional storage management methods
Definition and characteristics of virtual storage
Implementation of Virtual Storage Technology
Basic page table and request page table
Operation when a page fault is interrupted
The difference between request paging and basic paging
Points to note when requesting pagination
11. Page replacement algorithm
1. Optimal permutation algorithm (OPT)
2. First-in first-out replacement algorithm
Note: Actually difficult to achieve
3. Least Recently Used (Least Recently Used)
4. Clock replacement algorithm (CLOCK)
5. Improved clock replacement algorithm
Comparison of replacement algorithms
12. Page allocation strategy
Jitter phenomenon: The page that has just been swapped into the memory will be swapped out immediately. Frequent page swapping in and out causes the process to fail to work properly. The main reason: the number of pages frequently accessed by the process is higher than the number of available physical blocks.
Thirteen, stack allocation
The memory occupied by a C/C++ compiled program is divided into the following parts:
- Stack area (stack) : automatically allocated and released by the compiler, storing function parameter values, local variable values, etc.
- Heap : It is allocated and released by the programmer. If the programmer does not release it, the OS may reclaim it when the program ends.
- Global area (static area) (static) : The storage of global variables and static variables are placed together, initialized global variables and static variables are in one area, uninitialized global variables and uninitialized static variables are in another adjacent area. An area.
- Text constant area: The constant string is placed here.
- Program code area: store the binary code of the function body.
The stack is a contiguous block in memory. A register called the stack pointer (SP) points to the top of the stack. At the bottom of the stack is a fixed address. One characteristic of the stack is that it is last in, first out. In other words, the data that is put in later is taken out first.
Heap is a data structure that extends to high addresses and is a discontinuous memory area. This is because the system uses a linked list to store free memory addresses, which are naturally discontinuous, and the traversal direction of the linked list is from low addresses to high addresses.
- In high-level languages, the program function calls and variables defined in the functions all use the stack.
- The variable space allocated by malloc, calloc, realloc and other functions is on the heap.
- What is defined outside of all functions is a global quantity.
- After adding the static modifier, no matter where it is placed, it belongs to a static variable and is stored in the global area (static area)
- The static variables defined outside the body of all functions are valid in this file and cannot be externed to other files.
- The static defined in the function body means that it is only valid in the function body.
- Strings such as "armfly" in the function are stored in the constant area.
int a = 0; //全局初始化区, 可以被其他c文件 extern 引用
static int ss = 0; //静态变量,只允许在本文件使用
char *p1; //全局未初始化区
void main(void){
int b; //栈
char s[] = "abc"; //栈
char *p2; //栈
char *p3 = "123456"; //123456\0在常量区, p3在栈上。
static int c =0; //全局(静态)初始化区
p1 = (char *)malloc(10); //在堆区申请了10个字节空间
p2 = (char *)malloc(20); //在堆区申请了20个字节空间
strcpy(p1, "123456"); /* 123456字符串(结束符号是0,总长度7)放在常量区,编译器可能会
将它与p3所指向的"123456"优化成一个地方 */
}
Reference: local variables, global variables, heap, stack, static and global