Storage management is the user area of the main memory as a contiguous area or divided into several contiguous areas are managed, it can be loaded in each successive zone a job.
Multiprogramming systems typically employ a plurality of partitions of the storage management, and specifically can be divided into a variable partition fixed partition in two ways.
A fixed storage management
The user area allocated in main memory can be pre-divided into several successive partitions, size of each successive zone may be the same or different. However, once a good division of the partition, the number of main memory on the fixed partition and the size of each partition is also fixed. This is a static zoning laws.
In the management of fixed partitions, each partition used to load a job. Since the main memory has a plurality of partitions, a job can be loaded simultaneously in each partition. So, this storage management for multi-channel programming system.
1, main memory space allocation and release of
To manage the use of the main memory space must be set a “main memory allocation table” (described partition table), in order to illustrate the distribution of the partitions. Main memory allocation tables to be noted that starting address and length of each partition, each partition is provided and a flag. When the flag is “0”, indicates that a corresponding partition is free partition, when the flag is other than “0”, it indicates that a corresponding partition has been occupied by a job. Free partitions can be used to hold the job.
When there are jobs in the job queue to be loaded into main memory, the storage management can be “order allocation algorithm” of main memory space allocated. See order main memory allocation table, a flag is found “0” and a length greater than or equal to the job to be loaded into the address space of the length of the partition, this partition to put the job table, the corresponding object flag into the job name identifier; if no such a free partition, then the job can not be temporarily loaded into main memory.
The release of main memory space is simple. After a job execution must be returned after the end of the share of the partition, then the storage management view of main memory allocation table based on job name, and find the corresponding entry, to which the flag is reset to “0” button.
2. Address Translation
NAT job fixed partition management techniques often static relocation.
3, memory protection
Fixed partition management mode is determined considering only its physical address. Often a “limit register to” process. If the lower limit address
Then continue Else have a “cross-border interrupt” interrupt handling routine cross-border transfer of
4. Memory Expansion
5. Advantages and disadvantages of fixed partitions
Advantages: simple, no external fragmentation
a. When the user program is too large, may not meet all the needs of the district, then we have to use technology to solve coverage, but this will reduce performance
B. A internal fragmentation, large fragments, the presence of small partitions occupies a large job, memory utilization is low.
The solution: using variable storage management
Second, the variable storage management
Variable partition mode memory management, also known as variable length partition mode, the dynamic partition allocation pattern. This distribution is not pre-divided memory partition, but when the process is loaded into memory, depending on the size dynamically create the partition process, and needs just right for the size of the partition process. Thus the number and size of the system partition is variable.
The difference between the fixed partition is: dynamic partitioning partition. To overcome the fixed partition management “internal fragmentation” problem.
1. Variable partition mode, the beginning, OS ready, but did not enter any user program memory before the whole user memory is a large space. Occupied zone and free partition is not absolute. 2. There must Fact Sheet to record the partition. 3. The program enters the routine work of memory is allocated spare area, and loader, and modify the free list and allocated area table. 4. Once a memory partition is assigned to a process that can be loaded into the block execution to be re-loaded positioning.
A variable partition allocated data structure
To use the system, what kind of data structure to record the memory usage?
Variable partition allocation algorithm
When loaded into memory to a new job, it requires a certain variable according to the partition allocation algorithm to select a partition to partition table of the job from the free (or free partition strand).
In the variable partition allocation method, when there are a lot of free time to meet the demand partition, which partition should be used be allocated?
We describe three variable partition allocation algorithm here
The first allocation algorithm to adapt
Algorithm idea: each time to start looking from the low address, find the first free partition size to meet.
Spare area addresses sorted from low to high => 1. Sequential search of each spare area, the first one found can accommodate application claims the memory area allocated to the applicant. (If the job length is greater than the free area, the free area is divided. portion of the idle part is assigned to the job.) => (2) adjust the idle allocated partition table and the partition table.
Rating: performance in general, but to achieve relatively straightforward, easy to merge adjacent space partition release. Easier to meet the needs of large operations. The average allocation to complete a required number of searches, affecting work efficiency.
Using the free area as far as possible a low memory address, but try to preserve a high free area address.
Best fit algorithm
Algorithm idea: Since the variable partition assignment is a continuous distribution, space allocated for each process must be continuous whole slice area. Therefore, to ensure that when the “big process” come to have a large continuous space, priority use of smaller free area.
Free partition capacity by increasing order link. Each assign sequential search free partition table when the memory size can be found to meet the requirements of the first free partition. Evaluation: as much as possible to retain a larger space. A large amount of small spare area can not be used. Therefore, this method will produce a lot of external fragmentation. The allocation algorithm so the effect is not necessarily the best.
As much as possible the use of small memory space area, and try to preserve large empty area.
The worst adaptation algorithm
Algorithm idea: To solve the problem the best fit algorithm – that is leaving too many small fragments difficult to use, can each allocation priority use the largest continuous free zone, free zone after this allocation will not be too small and easier to use.
Free partition in descending order according to the capacity of the link. Each assign sequential search free partition table when the memory size can be found to meet the requirements of the first free partition.
Rating: produced after splitting the free areas are generally still be allocated for future use. After working for some time, can not meet the large job requests for free areas.
Using a memory large free area as much as possible.
Comparison of three algorithms:
Variable partition memory recovery
An increase of only merge adjacent free area of operation than the fixed partition management. Mainly to reduce the timely arrival of “foreign debris”, which will help in the future big job. Achieve recovery of memory space, the key is to modify the free partition table and has been assigned the partition table.
You may experience memory partition recovery when four cases:
(A) If both ortho release zone R the free area, there are lower adjacent free area. The three free zones merge into a large empty area.
First referred to as R F2 and F2 were combined, then combined F1 and F2 referred to as F1, F2 and removed from the chain.
IF (B + H1 = C) AND (C + L2 = D) THEN modify the free list, the allocation table. (B) If only the release zone R o free area F1. Only the size of the free area F1 can be modified.
IF (D + H2 = E) THEN modify the free list, the allocation table.
(C) only under the free zone neighborhood
Modify the first address F2 free zone. F2 = F2 is the size of the size of the size + R (D) neither upper nor lower adjacent free area o Else modified release area is the start of the first free area
Storage protection partitions
If the lower limit address
Elimination of the “internal fragmentation” caused by a fixed partition management, but inevitably lead to “foreign debris” in the memory space. Using mobile (compression) techniques. Timing or when memory is tight, move to the end of all jobs in the memory RAM, it adjacent. After tightening process after location in memory has changed, if not for the program and address of the data to be modified, the process will not run. To make it run, must be “dynamic re-positioning” Note: = “crunch time: (1) if there is the return of the district will be tight, large system overhead. (2) each assignment algorithm found spare area is not enough, but sufficient, and when. This method is small tightening spending, more practical. Thus, the actual variable partition allocation algorithm than the fixed partition allocation algorithm is mainly to increase the “tightening” operation
Third, the buddy system (buddy system)
The buddy system can be seen as a compromise fixed and variable allocation through the partition allocated. When using the buddy system, memory is a power of 2 bytes as the size of the free block allocation unit. At startup system, only one of the largest power-of-2 free block, it is the entire available memory space. When an application process memory, the system will give it greater than or equal to a minimum process size of a power of 2 free block requested. For example, a memory request presented 50KB process will first be rounded up system, into a request for a free block of 64KB. If such a free block size do not exist at this time, can be obtained at this time is a minimum ratio of the free block size of the free block is divided into two “partners” units. For which a partnership units of sub-process may have to continue until a free block up to 64KB. Memory release algorithm buddy system to consider merging the two partner units into one big one times the idle units. And the merger process will continue recursively until it can not continue until the merger.
Observe under FIG combined idle block must be a power of 2 bytes in order to achieve a buddy system, a system to maintain the free block list for each possible free block. Set of available memory management system for a total of 2N bytes, a maximum of buddy system requires maintenance N free block list. Since each block has a size of the empty queue free block, the memory allocation and release and therefore can effectively. The biggest drawback partner system is not efficient use of memory, especially in the severely fragmented. For example, a 257KB of 512KB process needs to occupy a unit of allocation, which will have 255KB of internal fragmentation. In addition, all merger partner unit as much as possible every time the memory release practices will reduce system performance, because just a good block may soon have to merge to points. An improved approach is to delay the timing of the merger. Today Linux use it.