Operating System - storage management

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 storage management partitions, in particular it can be divided into fixed partitions and variable partitions 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, find a flag is "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 <Physical Address = <= upper limit address

Then continue
Else have a "cross-border interrupt" interrupt handling routine cross-border transfer of

4. Memory Expansion

Mulching technology

5. Advantages and disadvantages of fixed partitions

Advantages: simple, no external fragmentation

Disadvantages:

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 into memory, depending on the size dynamically create the partition process , and needs just right for the size of the partition process. Thus the system size and number of partitions 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 no user program is not in the top memory for the entire user memory area 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.

Implementation steps:

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.

Implementation steps:

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.

Implementation steps:

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 than the fixed partition management merge adjacent free zone operations.
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.


The IF (Hl = B + C) the AND (C + D = L2 of)
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.

 

 The IF (= H2 of D + 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

Address Translation

Dynamic relocation

Storage protection partitions 

     If the lower limit address <Physical Address = <= upper limit address
     Then continue
     Else produce a "cross-border interrupt" interrupt processing routine cross-border transfer

Memory Expansion

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

 

Guess you like

Origin www.cnblogs.com/wkfvawl/p/11687619.html