Some storage concepts are useful. You need to encapsulate the memory allocation function.

Source: Internet
Author: User

Continuous Storage Allocation
1. Fixed partitioning
A fixed partition is divided into several partitions before a job is loaded. The Division can be completed by the system administrator,

It can also be implemented by the operating system. However, once the division is completed, the Division will not be repeated during system operation, that is, the number of partitions is unchangeable,

The partition size is immutable. Therefore, a fixed partition is also called a static partition.
This partitioning method generally divides the user area of the memory into partitions of a size ranging from large to small to meet the needs of jobs of different sizes. System

A partition description table is provided. Each table describes the size, start address, and usage of a partition.

Fixed partitioning
Partition description
Area code size start mark
1 16kb 20 k allocated
2 32 KB 36 K allocated
3 64kb 68 K allocated
4 124kb 132 k unallocated
The implementation of fixed partitions is simple, but the memory usage is not high. It is suitable for jobs with clear size and quantity.

System. It was used in the MFT Operating System of IBM-360 in 1960s.

2. Dynamic/variable (Dynamic partitioning) Partition allocation
Variable partitioning refers to allocating a continuous area from the available memory when a job is loaded into the memory, and the partition is large.

The size is equal to the size of the job. In a variable partition, the partition size and the number of partitions are variable and vary according to the job size.

Dynamic partitioning is also called dynamic partitioning. This storage management technology is an improvement of the fixed partition, which can not only obtain

High flexibility and improved memory utilization.
The basic idea of variable partition allocation and release is: when assigning, first find a free partition that is large enough, that is, this empty

The size of the free zone is larger than the size required by the job. The system divides the free partition into two parts: one part is the allocated partition, and the remaining partition is

Is still used as the free zone. When recycling and removing the partitions occupied by the job, check whether the recycled partitions are consistent with the idle partitions.

If yes, merge them to form a large continuous space.

Dynamic/variable (Dynamic partitioning) Partition allocation
1. Variable partition Data Structure
Free Partition Table Format
An idle partition table sets a table item for each unallocated partition, including the sequence number, size, start address, and status of the partition. Free Zone

Chain form
In order to allocate and link idle partitions, set some information for controlling partition allocation in the starting part of each partition.

(Such as the partition size and status bit) and forward pointer used to link other partitions; at the end of the partition, a backward pointer is set.

For ease of retrieval, the information for controlling partition allocation is also set. Then, use the forward and backward pointers to link all the partitions into one

Two-way linked list.
Dynamic/variable (Dynamic partitioning) Partition allocation
No. P address Starting Status
1 32 K 20 k idle
2 56 K 260 K idle
3 116 K 396 K idle
4--empty table category
5--empty table category

2. Partition allocation algorithm (partitioning placement algorithm)
Best fit ):
It finds the idle partitions that meet the job requirements and have the smallest size from all the free zones. This method can minimize the fragmentation.

To adapt to this algorithm, the idle partitions in the idle Partition Table (idle partition chain) should be sorted by size from small to large, starting from the header

To the first free partition allocation that meets the requirements. This algorithm retains large idle areas, but causes many small idle areas.
First fit ):
This method searches for the table from the first table in the idle Partition Table and assigns the idle table that meets the requirements to the job.

The goal is to reduce the search time. To adapt to this algorithm, the idle partitions in the idle Partition Table (idle partition chain) need to go from low to high by address.

Sort rows. This algorithm takes precedence over some idle zones with low addresses, resulting in many small idle zones in the low address space.

Free Zone.
Next fit ):
This algorithm is the first variant to adapt to the algorithm. When allocating memory space, you do not start searching from the header (beginning with the chain) every time, but from

Find the next idle zone in the idle zone until you find the first free zone that meets the requirements, and draw one from it.

Memory space equal to the request size is allocated to the job. This algorithm makes the idleness in the memory evenly distributed.
(4) dynamically relocated partition allocation
1. Compaction/stitching
Variable-type partitions also have zero header issues. In the continuous distribution and recovery of the system, there will certainly be some non-consecutive small idle areas.

It is called fragment ). A small idle area is called an external zero header, and the idle part in a fixed partition is called an internal zero header.

Although the sum of all the zero headers may exceed the requirements of a job, it cannot be allocated due to the discontinuous nature. The solution to zero header is tight

Merge (or join), that is, move the assigned jobs to one direction (for example, to the low-address end), so that the scattered idle areas are in another

One Direction is connected. Partition splicing technology, on the one hand, requires the ability to relocate jobs, on the other hand, the system needs

It takes a lot of time.
2. Dynamic Relocation
Hardware Support is required to implement Compact technology that allows jobs to move in memory during operation. Only dynamic

Only when the computer system of the hardware organization is relocated can the variable partition multi-channel management technology be adopted dynamically.

Locate registers and processors.

3. Dynamic relocated partition Allocation Algorithm
There are two different solutions for memory compression in dynamic relocation partition management:
Immediately after a partition is released, the system always has only one continuous partition without fragmentation. This method is very costly.
When the "request Allocation Module" cannot find a large enough free partition to be distributed to the user, then tighten the number of such tightening than the previous method

But table management is complicated. Block Diagram of the dynamic relocation Partition Distribution Algorithm using this method.
4. Partition Protection
A common method of partition protection is to provide hardware by the system: a pair of boundary registers. This can be an upper-bound register or a lower-bound register.

Or base address register or limit length register. The base address register stores the starting address and is used as a relocation (address ing ).

Long register stores the program length for storage protection.

 

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.