The storage Management method detailed _ operating system

Source: Internet
Author: User
Chapter III Storage Management

Storage management is an important part of operating system, it is responsible for the management of memory space of computer system. The goal is to make full use of memory space, providing a storage base for concurrent execution of multiple programs and making it as user-friendly as possible. 3.1 Purpose of storage management

Multi-Program Design technology, it is necessary to store multiple programs in memory at the same time, which requires storage management to solve the following four important issues to achieve the most user-friendly and full use of memory to improve memory utilization purposes.

I. Allocation and recovery of memory space

Sharing and storage protection of memory space

Iii. address mapping (address relocation)

Four, memory expansion 3.2 Single user continuous storage management

This is the simplest type of storage management, the system is the entire memory in addition to the operating system partition a space, the rest of the space is allocated to a job to use. Personal computer can adopt this kind of management method, it is not suitable for multi-channel program design system.

The address map can be completed by static relocation, and when the processor executes the instruction, it checks whether its absolute address is within the specified range and, if it is, accesses it by this address, otherwise it will result in an "address crossing" interrupt.

Some systems also use the Swap technology (swapping) to allow multiple processes to take turns into memory, this technology is used in time-sharing system, with the process scheduling, the process of memory temporarily moved to the external memory, and the external storage of a process into the RAM. 3.3 Fixed partition Storage management

The basic idea is to divide the memory into a number of fixed-size partitions, with a maximum load of one job per partition. When the job requests memory, the system chooses an appropriate partition for it in a certain algorithm and loads the memory to run. Because the partition size is fixed beforehand, the size of the operation can be limited, and storage space is wasted when the user's job address space is less than the partition's storage space.

Allocation and recovery of space

The system sets up a "Partition allocation table" to describe the use of each partition, and the contents should include: partition number, starting address, length, and occupancy flag. Where the occupancy mark is "0", it means that the partition is currently idle, otherwise the registration occupies the job name (or job number). With the "Partition Allocation table", the space allocation and recycling work is relatively simple.

Ii. address Translation and storage protection

Fixed Partition management can address mapping using static relocation.

To achieve storage protection, the processor sets a pair of "lower register" and "upper bound registers". When a job that has been loaded into the main memory can get the processor running, the process dispatch should record the partition number of the current running job and send the lower and upper address of the partition into the lower register and the upper register respectively. When the processor executes the instructions for the job, it must check that the absolute address to which it is accessing is out of bounds.

Fixed Partition management of multi-job queues

In order to avoid the waste of space caused by the assignment of small jobs to large partitions, the method of multiple job queues can be used. That is, the system sets up multiple job queues by number of partitions, rows the jobs by their size into different queues, and one queue corresponds to one partition to increase memory utilization. 3.4 Variable Partitions

Variable partitioning storage management does not partition memory in advance, but builds partitions when the job is loaded into memory, making the partition exactly the same as the storage space required by the job. This approach allows for greater flexibility in memory allocation and increased memory utilization. However, as memory is allocated and released, it can cause storage fragmentation.

Allocation and recovery of space

Variable partition storage Management, the number of partitions in the system and the size of the partition are constantly changing, the system uses the "Free Zone table" to manage the free partition in memory, which registers the start address, length and state of the free zone. When there is a job to enter into memory, find the idle partition with the status unassigned and the length greater than or equal to the job in the idle table to assign to the job and adjust it appropriately; When a job runs, the space occupied by the job should be returned to the system as a free zone.

Memory allocation can be carried out by using one of the three allocation strategies, the first adaptive algorithm, the best adaptive algorithm and the worst fit algorithm.

First, the adaptive algorithm: from the first table of the free partition table to find the table, the first to meet the requirements of the idle to distinguish the allocation of jobs, this method is to reduce the search time. To accommodate this algorithm, free partitions in the free partition table (free zone chain) are sorted by address from low to high. This algorithm gives priority to the low access part of the free area, causes many small free areas in the low access space, and retains the large free area in the high address space.

Best Fit algorithm: It finds free partitions of the smallest size that meet the job requirements from all the free areas, which makes the fragments as small as possible. To accommodate this algorithm, free partitions in the free partition table (free zone chain) are sorted from small to large, starting with the table header to find the first free partition allocation that satisfies the requirement. The algorithm retains large free areas, but causes many small free areas.

Worst fit algorithm: The worst fit allocation algorithm to scan the entire free partition or linked list, always pick one of the largest free partition to the job use. The algorithm requires that all the free partitions form an idle partition chain in the order of their capacity from large to small, so as to see if the first partition can meet the operational requirements. The remaining free partition is not too small, the probability of producing debris is the least, it is advantageous to medium and small operations, and the algorithm is very efficient to find. But at the same time, there is a lack of large free partitions in the memory.

Ii. address Translation and storage protection

Variable partition storage Management generally uses dynamic relocation, in order to achieve address relocation and storage protection, the system sets the corresponding hardware: base/Limit register (or upper/lower register), adder, comparison lines.

The base register is used to store the starting address of the program, which is used to store the length of the program. When the processor executes, it uses the relative address in the program and the base address in the base register to form an absolute address, and compares the relative address with the limit register to check whether the address crosses over.

Iii. storage fragmentation and movement of programs

The so-called fragment is the memory of some of the scattered small free areas. Because the fragments are very small, can not be used. If there is a lot of fragmentation in memory, it will cause serious waste of storage resources. The solution to the fragmentation is to move all the occupied areas so that all the free areas are merged into a contiguous area, a technology called mobile Technology (compact technology). In addition to solving the fragmentation problem, mobile technology expands in-memory jobs. Obviously, the movement brings overhead, and the job cannot be moved if a job is being I/O with the peripheral. 3.5-page Storage Management

3.5.1 Fundamentals

1. Divide the memory into halves

Page-type storage management divides the memory space into several areas of equal length, each of which is generally the size of an integer of 2, called a physical page, sometimes called a block. All physical pages of memory are numbered starting with 0, called physical page numbers.

2. Logical Address

The system divides the logical space of the program into several pages according to the same size, called the logical page also called the page. Each logical page of the program is numbered sequentially from 0, called the logical page number or relative page number. Each page is addressed from 0, called the address inside the page. The logical addresses in a program are made up of two parts:

Logical Address

Page number P

In-page address D

3. Memory allocation

The system can use a "bit map" to register the allocations of each block in memory, to store allocations in pages (blocks), and to allocate the number of pages in the program. Adjacent pages are not necessarily contiguous in memory, which is not necessarily contiguous between the memory blocks that are allocated to the program.

Paging to the program address space is done automatically by the system, which is transparent to the user. Because the page size is 2 of the whole number of power, so the relative address of the high part of the page number, the lower part of the page address.

3.5.2 Realization Principle

1. Page table

The system creates a page table for each process that records the correspondence between the process logical page and the memory physical page. The number of pages in the address space, how many rows are registered on the page, and in the order of the logical pages, in the form of:

Logical page number

Main memory block number

0

B0

1

B1

2

B2

3

B3

2. Address mapping process

The page storage management adopts dynamic relocation, that is, the address translation is done during the execution of the program. The processor executes an instruction every the logical address in the instruction (P,D) is taken to get the logical page number (p), the hardware mechanism of the page to check the page table, get the memory block B ', then form an absolute address (b ', d), the processor that is the address to access main memory.

3. Sharing and protection of pages

When you need to have the same page information in several different processes, you can keep only one copy in main memory, as long as they point to the same number in their respective items. Also set the appropriate access permissions in the page table to make all the necessary restrictions on the access rights of different processes. 3.6-Segment Storage Management

3. 6. 1 Basic Principles

1. Logical address space

The program is divided logically into segments that have complete meaning, called logical segments. For example, the main program, subroutine, data, etc. can be in a paragraph. Numbering all logical segments of a program from 0 onwards is called a segment number. Each logical segment is addressed from 0, called the address in the paragraph.

2. Logical Address

The logical address in the program consists of part number and the address (S,D) in the paragraph.

3. Memory allocation

Instead of prior partitioning, the system allocates memory in segments, allocating a contiguous memory area (physical segment) for each logical segment. Logically contiguous segments are not necessarily stored continuously in memory.

3. 6. 2 Implementation Methods

1. Cong

The system establishes a segment table for each process that records the correspondence between the logical segment of the process and the memory physical segment, at least including the logical segment number, the first address of the physical segment, and the three-item length of the segment.

2. Create a free zone table

A Memory Free area table is set up in the system to record the idle area in memory, which is used for segment allocation and reclaim memory.

3. Address mapping process

Segment-type storage management uses dynamic relocation, and the processor takes the logical address (S,D) from the instruction to get the logical segment number (s) from each executing instruction. The hardware organization according to this paragraph to look up the section table, obtains this paragraph in the memory the first address s ', that paragraph in the memory first address s ' plus the paragraph address d, then forms the absolute address (s ' + D), the processor accesses main memory at this address.

3. 6. 3-segment Page storage Management

The characteristics of page storage management are divided into memory, which solves the fragmentation problem; Segment storage management is characterized by logical segmentation and facilitates sharing. In order to maintain the advantages of page and section, the paper combines two storage management schemes to form a segment-page storage management.

The basic idea of Segment-page storage management is to divide the memory into pages of equal size, divide the program into several sections according to its logical relation, and divide each paragraph into several pages according to the page size. The logical address of the program consists of three parts, in the form as follows:

Logical Address

Paragraph number s

Page number P

In-page address D

Memory is assigned to each program in the base unit of the page, and logically adjacent page memory is not necessarily contiguous.

The system creates a section table for each process, creating a page table for each segment of the process. Address conversion process, to go through the Section table, page table to get the final physical address. 3.7 Virtual Storage Management

One of the different storage management scenarios described earlier is that when a process that participates in concurrent execution is running, its entire program is in memory, and the disadvantage is that the process cannot run if the size of a process is larger than the amount of memory available; A process uses only part of the storage space at any stage of the run, so unused memory areas are wasted.

Virtual Storage Management is when a process requires that the runtime not load all of its information into memory, but instead loads its part into memory, while the other part is temporarily left out (usually a disk). When a process is running, if the information to be accessed is not in memory, the interrupt is transferred by the operating system into memory to ensure that the process is running properly.

Virtual Storage Management is divided into page-type virtual Storage Management, Segment-type virtual storage management, and segment-page virtual storage management.

3.7.1-page Virtual Storage Management

First, the basic principle

The basic idea is that before the process starts, instead of loading all the pages, just load one or several pages, and then dynamically load the other pages as needed for the process to execute.

A number of items will be added to the page table: the flag bit (also known as the resident bit), indicating whether the page is loaded in memory, and the external address gives the address of the page in the external storage (disk).

An address map is interrupted when the page is not in memory from the page table flag bit. At this point suspend the process execution, the CPU to carry out the page fault interrupt handler, responsible for the required pages from the external storage into the memory of a free block, and the physical page number fill in the page table, change the flag bit, and then return to continue to execute the interrupted process.

Second, the page elimination

When there is no free block of memory and a missing page interrupt, you must select one of the pages in memory to be eliminated and write back to the external storage, and then into a new page, this process is called page scheduling, the choice of the elimination of the page algorithm is called page scheduling algorithm. If the page elimination algorithm is unreasonable, may have just been eliminated a page, but also to access it, and then put it into, so repeatedly, so that the system's page into the paging work very frequently to reduce system efficiency, this phenomenon known as "bumps" or "jitter."

Commonly used page scheduling algorithms are: FIFO, the least Recently used scheduling algorithm (LRU), and most recently the least frequently used scheduling algorithm (LFU).

Note that virtual storage management is not possible for single user continuous, fixed partitioning, and variable partitioned storage management because they have in common the whole, contiguous memory of the entire job when allocating memory to a job.

********************************************************************************************************

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.