OS review---memory management

Memory management

Program loading and linking

To change a user source program into a program that can be executed in memory, there are the following steps:

  • Compile: The compiler compiles the user source code into several target modules
  • Link: The linker links the compiled object modules and their required library functions into a complete loadable module
  • Load: The loader loads the load module into memory

Program link

According to the link time, it can be divided into the following three types:

  • Static link : a way to link before the program runs
  • Dynamic linking when loading: when loading the memory, linking while loading
  • Run-time dynamic linking : When the target module is needed during program execution, it is only linked.

Program loading

A load module is loaded into memory, there are 绝对装入, 可重定位装入and 动态运行时装入three ways

  • Absolute loading mode : directly load the target module into the memory designated location (specific physical address), which is only suitable for a single program environment.
  • Relocatable loading mode : Because the loaded module uses a logical address, which is different from the physical address actually loaded into the memory, a relocation is performed during loading (the instructions and data in the target program are modified, because After loading, the transformed address will not change again, so it is also called static relocation).
  • Dynamic runtime loading : After the program is loaded into the memory, the relative address in the loaded module is not converted to an absolute address immediately, but the address conversion is postponed until the program is actually executed.

Continuous distribution method

Refers to the allocation of a contiguous memory space for a user program . The continuous allocation method can be divided into four methods: single continuous allocation, fixed partition allocation, dynamic partition allocation, and dynamic relocation partition allocation.

  • Single continuous allocation : The memory is divided into the system area and the user area. In this way, all user programs are directly allocated to the user area. It can only be used in a single-user, single-task operating system.
  • Fixed partition allocation : The memory user space is divided into several fixed-size areas, and only one job is transferred to one partition at a time. Several jobs in different partitions can run concurrently. This is the simplest way to manage the storage of multiple programs.
  • Dynamic partition allocation : According to the actual needs of the process, dynamically allocate memory space for it.
    This method requires the system to configure a free partition table or free partition chain to describe the situation of free partitions and allocated partitions.
  • Relocatable partition allocation : If there are only a few small partitions in the current system, although their total capacity is greater than the program to be loaded, because these partitions are not adjacent, the program cannot be loaded into the memory.
    In order to solve this problem, dynamic relocation is to move all the jobs in the memory so that they are all adjacent, thereby splicing multiple small partitions into one large partition.
    But at this time, the address of the program and the data needs to be changed, and hardware support is needed, that is, a relocation register is added to the system to store the starting address of the program in the memory.

Swap

Refers to the process of temporarily unable to run in the memory or temporarily unused programs and data are scheduled to the external memory to free up enough memory space, and then the process or the programs and data required by the process that have the running conditions are transferred into the external memory . Memory .

If the unit of swap is a process, it is called "process swap" ("whole swap"); if the basic unit of swap is "page" or "segment", it is called "page swap" and "segment" respectively. "Segment swap", the two are collectively referred to as "partial swap".

Guess you like

Origin blog.csdn.net/why1092576787/article/details/114848214