* Storage Management-3

Source: Internet
Author: User

2.3 Storage Management

Memory Management objects are primary memory (primary memory, memory ).

Main functions include allocating and recycling primary storage space, improving primary storage utilization, and expanding primary storage space to effectively protect primary storage information.

2.3.1 Basic Concepts

1. Memory Structure

There are two general structures: Register-main memory-external memory

Register-Cache-primary storage-External Storage

Storage Organization function: organizes a reasonable storage structure within the scope permitted by storage technology and CPU addressing technology,

Make all levels of memory in a balanced and busy state

(1) Virtual Address: For programmers, the data storage address is determined by the symbol, so it is called the symbol name address.

The address unit starts from unit 0 and is allocated sequentially to all address units corresponding to symbol names. Because the symbolic name address is not the real address in the primary storage, it is also called the relative address, program address, logical address, and virtual address.

(2) address space. The space in the program composed of relative addresses is called the logical address space. The relative address space passes through

The address is then switched to the absolute address space. The absolute address space is also called the physical address space.

Conclusion: The logical address space is a set of logical addresses, and the physical address space is a set of physical addresses.

2. Address relocation.

The process of converting a logical address to a primary physical address is called address relocation.

Address relocation includes static and dynamic address relocation.

(1) static address relocation. That is, the conversion has been completed when the program is loaded into the primary storage.

Advantage: The hardware address translation mechanism is not required. It only requires that the program itself be relocable.

Disadvantage: You must allocate a continuous storage area to the job. during the execution of the job, you cannot expand the storage space or move it in the primary storage, it is difficult for multiple jobs to share data of the same program copy in the primary storage.

(2) Dynamic address relocation. That is, the exchange is completed during the program running.

Advantage: during the execution of the program, you can switch in and out of the main memory, and the program can move in and make full use of the space. You can buy and share data.

2.3.2 Storage Management Solution

The main purpose of storage management is to solve the problem of multiple users using primary storage.

It mainly includes partition storage management, paging storage management, segmented storage management, segment-page storage management, and virtual storage management.

(1) Partition storage management, early solutions,

Partitions can be divided into fixed partitions, variable partitions, and relocated partitions.

Fixed partition: a static Partition Method

Variable partitioning: a dynamic Partitioning Method

You can reset the partition. To solve the fragmentation problem, the basic idea is to move all allocated partitions to make them continuous areas, with code and address changes, so there is an address relocation problem.

Partition protection: Generally, upper and lower bound registers are used.

The load address of the upper-bound register to store the job. End address of the next register load job

The physical address must meet

Upper-bound register <= physical address <= lower-bound register

Or use base address registers and limit-length registers,

Base Address Register stores the loading address of the job, limit length register stores the length of the job,

The physical address must meet the following requirements:

Base address register <= physical address <= base address register + limit register

2.3.3 paging Storage Management

The solution is that user programs must be loaded into consecutive address spaces. In the partition management solution, if not, partition close operations are required, which takes the system time. Therefore, the paging storage management solution is introduced.

1. Paging-only Storage Management

1) Paging Principle

Divides the address space of a process into several areas of the same size, called pages. Correspondingly, the primary storage space is divided into several physical blocks of the same size as the page, it is called a block or page box. When Assigning primary storage to a process, you can load several pages in the process into multiple non-adjacent blocks.

2) Address Structure

The address structure of the paging system is 2-10.

Features: 32-bit. Pay attention to the figure.

 

1) page table

After each page of a process is discretely allocated to multiple physical blocks in the memory, the system ensures that the physical blocks corresponding to each page can be found in the memory, the system creates a page injection table for each process.

 

2. Fast table

2.3.4 Segment Storage Management

Segment is the logical unit of information. Therefore, a prominent advantage of the segmentation system is that it is easy to share segments, that is, it allows several processes to share one or more segments, and can easily implement segment protection. When sharing programs and data, it is often based on the logical unit of information. Each page in the paging system is only the physical unit for storing information. It has no complete meaning, therefore, it is not easy to share information, but the segment is the logical unit of information, which is conducive to information sharing and protection.

1. Basic principles of segmentation

In the management of segmented storage, the address space of a job is divided into several segments, each of which is a complete set of logical information,

It is a continuous address space from scratch. Each segment has a length of varying length. A job can have a maximum of 64 K segments,

The maximum length of each segment is 64 KB.

 

In the segmented Storage Management System, a continuous partition is allocated to each segment. The process and segment can be allocated to different memory partitions discretely. In the system, a field ing table is created for each process, field table. Each segment occupies one table item in the table, which records the starting address (base address) of the segment in the memory ). And segment length. Compare the length of the middle table in the field table register with the segment number in the logical address. If the segment number exceeds the length of the segment table, an out-of-boundary interruption occurs.

2.3.4 virtual storage management

In the storage management solution described above, you must allocate sufficient space for each job and load all information. When the primary storage space cannot meet the job requirements, the job cannot be loaded into the primary storage for execution. Virtual Storage Management solves this problem.

That is, you can load part of the content to run, and the rest of the content is temporarily on the disk, and the primary storage is loaded as needed.

1. Implementation of Virtual Memory

The virtual memory has the Request Transfer and replacement functions. you can load a part of the job into the primary storage to start running and logically expand the primary storage capacity. The logical capacity of the virtual memory is determined by the sum of the primary and external memory capacity and the range of CPU addressable. The running speed is close to that of the primary memory. There are three main ways to implement virtual memory.

(1 ). Request paging system.

Based on the paging system, a page-based virtual storage system is added based on the page request and Page Replacement functions. It allows only user programs and data (not all programs) loaded on several pages to start running and then use the paging and page conversion functions, in succession, the pages to be used are transferred to the primary storage, and the temporarily unavailable pages are replaced with the external storage. The replacement is based on the page.

(1) Request a segmentation system. On the basis of the segmentation system... The request paging system is the same, but it is a segment. Note that it is a segment, not a page.

(2) Based on the segment-based system, a segment-based virtual storage system is added based on the request paging and Page Replacement functions.

2. Implementation of request paging Management

Request paging is a webpage-based virtual storage system based on the pure paging system. It is a common virtual storage method.

Request paging is a webpage-based virtual storage system based on the pure paging system. It is a common virtual storage method.

The page table mechanism of request paging is formed on the page table mechanism of pure paging, because only part of the application is transferred to the primary storage, and some are still stored, therefore, you need to add several items in the page table, such as the status bit, access field, and secondary storage address, for the program to switch in and out for reference.

* ** In the request paging system, every time the page to be accessed is not in the primary storage, a page missing interruption occurs. When a request is transferred to the missing page, the main difference between page missing interruption and general interruption is, page-missing interruptions generate and process interruption signals during command execution. Generally, after a command is executed, the next command starts to check and process the interruption signal, in the missing page, the interrupted command is returned to start to re-execute the command. In general, the interrupted command is returned to the next command for execution. During the execution of a command, the page may be interrupted multiple times.

3. Page Replacement Algorithm

To ensure normal operation of a process, you do not have to call up one page of programs or data from the memory to the swap zone of the disk. However, a page replacement algorithm is required to determine which page to call up. The commonly used page conversion algorithm is as follows:

1) optimal (optimal) Replacement Algorithm

This algorithm is used to replace pages that are not used or are no longer accessed for the longest time. However, it is difficult to estimate which page will not be accessed for the longest time in the future.

Analysis: Page loss occurs when a process accesses page 5. According to the best replacement algorithm, page 0 is accessed only once, which is the page that will not be accessed for the longest time on the three pages. So it is eliminated. And so on.

1) first-in-first-out (FIFO) Replacement Algorithm

This algorithm always removes the page that first enters the memory, that is, it selects the page with the most resident time in the memory for elimination. This algorithm is easy to implement, you only need to link pages that have been transferred into memory in a process into a queue in order. However, poor performance may lead to Belady exceptions. The so-called Belady Phenomenon, if you do not allocate all pages required by a process, the number of allocated pages increases but the page missing rate increases. For example: the page access sequence is ABCDABEABCDE. The number of physical blocks increases from 3 to 4, and the number of missing pages increases.

1) Least Recently Used (Least Recently Used, LRU) Replacement Algorithm

Select the least used page for elimination. The system sets an Access Field on each page to record the time T this page has experienced since its last access. When you want to delete a page, select the page with the maximum T value.

4) Recently unused (Not Used Recently, NUR) Replacement Algorithms

This algorithm is similar to LRU for pages that have not been referenced recently. This algorithm sets an access bit for each page and connects all pages in the memory to a cyclic queue through link pointers, when a page is accessed, its access location is 1. When a page is selected for elimination, check its access location. If it is 0, select this page for replacement.

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.