Process load evolutionary history (process loading and memory storage management)

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_6f5e19860102vlv0.html

Fundamentals of Storage Management

Memory Management methods

Memory management mainly includes memory allocation and recycling, address transformation, memory expansion, memory sharing and protection functions.

The following is a brief introduction to the basic concepts and principles of continuous allocation storage management, overlay and switching technology, and page-and segment-based storage management.

1 . continuous allocation of storage management methods

Continuous allocation refers to the allocation of contiguous memory space for a user program. There are two ways of continuous allocation: Single continuous storage management and partitioned storage management.

(1) single Continuous Storage management

In this mode of management, memory is divided into two regions: the system area and the user area. The application is loaded into the user area to use all the space in the user area. It is characterized by the simplest, suitable for single-user, single-tasking operating systems. Cp/m and DOS 2. 0 This is the way it is used. The greatest advantage of this approach is ease of management. However, there are some problems and shortcomings, such as the requirement of less memory space of the program, resulting in memory waste, the program is all loaded, so that very little use of the program part also occupies-a fixed amount of memory.

(2) Partitioned Storage Management

In order to support multi-channel program system and time-sharing system, multiple programs are implemented concurrently, and partitioned storage management is introduced. Partitioned storage management divides memory into partitions that are equal or unequal in size, the operating system occupies one of the partitions, and the remaining partitions are used by the application, and each application occupies one or several partitions. Although partitioned storage management can support concurrency, it is difficult to share memory partitions.

Partitioned storage management introduces two new problems: internal and external fragments. The former occupies unused space within the partition, which is an idle partition (usually a small free partition) that occupies a hard-to-use partition between partitions. To implement partitioned storage management, the operating system should maintain a data structure that is a partitioned table or a list of partitions. The table entries in the table typically include the start address, size, and state (whether allocated) for each partition.

One of the techniques commonly used for partitioned storage management is memory crunch (compaction): moving each occupied partition to one end of the memory and then merging each free partition into an idle partition. This technology provides some degree of flexibility, but also there are some drawbacks, such as: to occupy the partition memory data to move occupy cpu~t-inch; If you "float" a program in a occupied partition, its relocation requires hardware support.

1) fixed partition (nxedpartitioning).

Fixed partitioning is characterized by dividing the memory into contiguous partitions of several fixed sizes. Partition size can be equal: This approach is only suitable for concurrent execution of multiple identical programs (processing multiple types of objects of the same type). The partition size can also vary: there are several small partitions, moderate partitions, and a small number of large partitions. Allocates the currently idle, appropriate-sized partitions based on the size of the program. The advantage of this technique is that it is easy to implement and less expensive. There are two disadvantages: internal fragmentation causes waste, the total number of partitions is fixed, and the number of concurrent execution programs is limited.

2) Dynamic partitioning (partitioning).

Dynamic partitioning is characterized by the dynamic creation of partitions, which are allocated by their initial requirements when the program is loaded, or are allocated through system calls during their execution or change the partition size. The advantage of comparing with a fixed partition is that there is no inner fragment. But it introduces another fragment--the outer fragment. Partition allocation for dynamic partitioning is the search for an idle partition whose size is greater than or equal to the requirements of the program. If it is greater than the requirement, the partition is split into two partitions, one of which is the required size and marked as "occupied," while the other partition is the remainder and marked as "idle." Partitioning is usually prioritized from low-memory to high-end. One of the issues to be aware of during partition release of dynamic partitioning is to merge adjacent free partitions into one large free partition.

The following is a list of several commonly used partition allocation algorithms:

First, the adaptation method (Nrst-fit): Find the first partition that meets the requirements in the memory order from the beginning of the partition to be allocated. The algorithm allocates and releases the time performance better, the larger free partition can be kept in memory high-end. However, as the low-end partitions are divided to produce more small partitions, the look-up time overhead increases with each allocation.

Next adaptation Method (Next-fit): By partition in the memory order, from the last allocated partition from the beginning of the lookup (to the last {zone and then start from scratch}, find the first partition that meets the requirements to allocate. The allocation and release time performance of the algorithm is better, so the free partition is distributed more evenly, but the large free partition is not easy to keep.

Best Fit Method (Best-fit): Locate the memory in the order of the partition from scratch, and find the size of the spare partition with the smallest difference between the requirements to allocate. In individual terms, the outer fragments are smaller, but overall, the advantage of having more outer fragments is that larger free partitions can be preserved.

Worst-fit Method (Worst-fit): Finds the largest free partition in the memory order from the beginning of the partition to be allocated. Basically do not leave small idle partition, not easy to form outer fragment. However, because large free partitions are not retained, the requirements for larger memory requirements are not easily met when the process needs to run.

2 . Covering and switching technology

The goal of introduction to overlay (overlay) technology is to run larger programs in smaller, usable memory. This technique is commonly used in multi-channel program systems, and is used in conjunction with partitioned storage management. The principle of covering technology is very simple, a program of several pieces of code or data segments, according to time to occupy the public memory space. The code and data for the necessary parts of the program (common functions) reside in memory, and optional parts (infrequently used) are usually stored in the external memory (overwrite file) and loaded into memory when needed. A module that does not have a call relationship does not have to be loaded into memory at the same time, and can overwrite each other. The disadvantage of coverage technology is that programming must divide the program module and determine the coverage relationship between the program modules, increase the complexity of programming, and load the overwrite files from external memory, in exchange for space saving in time extension. Overrides are implemented in two ways: as a function library or operating system support.

Exchange (swapping) technology when multiple programs are executing concurrently, you can send a program that is temporarily unavailable to external memory to get free memory space to load a new program, or to read a program that is in a ready state in external memory. The swap unit is the address space for the entire process. Switching technology is often used in multi-channel program systems or small time-sharing systems, in conjunction with partitioned storage management, also known as "swap" or "roll-in/roll-out" (roll-in/roll-out). One of its advantages is to increase the number of concurrent running programs and provide users with appropriate response time; Another significant advantage of switching technology compared to overlay technology is that it does not affect the program structure. The switching technology itself also has shortcomings, for example: the control of substitution and swap increases the processor overhead, and the entire address space of the program is swapped, without considering the statistical characteristics of address access during execution.

3 . Page-and Segment-Storage management

In the previous storage management methods, the space allocated for the process is contiguous and the address used is the physical address. If you allow a process to be dispersed across many disjoint spaces, you can avoid memory crunch and reduce fragmentation. Based on this idea, the process address space is separated from the actual storage space by introducing the logical address of the process, which increases the flexibility of storage management. Address space and storage space two basic concepts are defined as follows:

Address space: The source program is compiled after the target program, exists in its limited address range, this range is called the address space. The address space is a collection of logical addresses.

Storage space: A collection of physical units that store information in main memory, which are called Physical address storage spaces as a collection of physical addresses.

Depending on the basic unit used in the allocation, the management of the discrete distribution can be divided into the following three types
Segment Storage Management and Segment-page storage management. One of the first two combinations of page storage management is the product.

(1) page-Storage Management

1) Fundamentals. The logical address space for a program is divided into fixed-size pages (page), and physical memory is divided into page boxes of the same size (pageframe). When the program loads, you can put any page in the memory of any one of the page boxes, the page boxes do not have to be contiguous, thus achieving a discrete allocation. This method requires the hardware support of the CPU to implement the mapping between the logical address and the physical address. In the page storage management mode, the address structure consists of two parts, the first part is the page number, the latter part is the in-page address, 4-2 is shown.

The advantage of this kind of management is that there is no outer fragment, and that each fragment does not exceed the maximum page size the greatest improvement in the management methods discussed earlier is that a program does not have to be kept in succession. This makes it easy to change the size of the program footprint (mainly refers to the increased number of dynamically generated data as the program runs, and the corresponding increase in the required address space). The disadvantage is that the program is still required to be loaded into memory, not enough memory, the program can not be executed.

2) page-managed data structures. When a process is established in a page system, the operating system assigns page boxes to all pages in the process. Retract all page boxes assigned to it when the process is revoked. During the run of the program, if the process is allowed to request space dynamically, the operating system also allocates a physical page box for the space requested by the process. In order to perform these functions, the operating system must record the system memory
The actual page box usage. The operating system also needs to correctly toggle the mapping of two different process address spaces to physical memory space while the process is switching. This requires the operating system to record information about each process page table. In order to accomplish the above functions, the following data structures are generally used in a page-based system.

Process Page Table: completes the mapping of the logical page number (the address space of this process) to the physical page number (actual memory space).
Each process has a page table that describes the physical pages that the process occupies and the logical order in which they are arranged.

Physical Page Table: The entire system has a physical page table that describes the allocation of physical memory space usage, and its data structure can be used in both the bit diagram and the free page list.

Request table: The entire system has a request table that describes the location and size of each process page table in the system, and is used for address translation to be integrated into each process's PCB (Process Control block).

3) page-managed Address transformation

Process load evolutionary history (process loading and memory storage management)

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.