Operating System - Memory management section

Memory has always been an important part of the computer system. It continues to be a valuable and scarce resource.

How to manage it to be effective, not only directly affect the memory utilization efficiency, but also affect the performance of the system.

The main object management memory is memory. When the computer to perform almost every instruction will involve access to memory.

Three memory ideal conditions ( these three conditions in terms of the technology is now possible to achieve simultaneous )

1. The access speed of the memory to keep up the operating speed of the processor.

2. The requirement to have a large capacity memory.

3. And the cost of memory should be low.

In modern computer systems, without exception, which employs the memory system of the multilayer structure .

 

The multilayer structure of the memory

For a general purpose computer, you should have at least three levels of memory: the CPU registers, main memory, secondary memory .

In the memory hierarchy among the higher the level, the faster the access speed of the storage medium, the higher the price, the smaller the storage capacity.

Registers, cache, main memory, disk cache belong within the jurisdiction of the operating system storage management. They saved after power failure message will disappear.

Fixed disks, removable storage media management belongs to the category of device management, the information will be stored in their long-term preservation.

 

Executable memory

In a computer system memory hierarchy among the registers and the main memory it is also called executable memory.

Executable processes can access memory using a load or store instruction within a few clock periods. Access to the auxiliary storage is required to implement the I / O devices, the time consumed by the executable memory access time is much larger than consumed, the general difference of three orders of magnitude or more.

OS storage management responsible for the allocation of the executable memory, recovery, and data exchange between various levels of storage management.

 

Main memory

Acronym main memory or main memory storage, is the main component of a computer, a process for the save process running program and the data, also called executable memory. Typically, the processor is fetching instructions and data from the main memory.

Since the main memory access speed is much lower than the speed of the CPU to execute instructions, to alleviate this contradiction, in which the computer system into the registers and caches.

 

register

Processor registers have the same speed, so the access speed of the fastest register, fully coordination with the CPU, but the price is very expensive, so the storage capacity is not large.

In current computer system with which medium-sized machines, the number of bits of registers 32 and 64 generally, and in the small embedded computer, the register bits is typically 8 bits.

 

cache

Cache is an important part of modern computer architecture, which is interposed between the memory and the register memory, the main memory is mainly used for backup data more commonly used to reduce the number of accesses to the main memory of the processor, so it may be larger the magnitude of increase running speed.

A high number of registers larger than the cache capacity, faster access than the main memory.

In a computer system, in order to ease the contradiction between memory and processor speed, many places have set up a cache.

Typically, the process of data and programs stored in the main memory of them, to be accessed only when, was temporarily copied to cache them. When the CPU accesses a specific set of information, first checks whether the information, if, taken directly from the cache in the cache which is not required to access main memory. Otherwise, you need to access main memory to obtain information.

Close to a cache memory of the highest speed, capacity minimum. Farther, the lower the speed, the greater the capacity.

 

Disk cache

Due to the current disk I / O speed is much lower than the speed of access to the main memory, in order to ease the contradiction between the two speeds, setting the disk cache, the main part of the disk for temporarily storing frequently used data and information to reduce disk access frequency.

Data must exist among the main memory, which can be outputted to the auxiliary storage.

 

Loading and linker

The user program becomes a program that can be executed usually go through the following steps:

1. compilation, the source program is compiled by the compiler, forming a number of object modules.

2. link, a set of the target module is formed by the compiler and linker library functions need thereof linked together to form a complete load module.

3. Load, the loader will load the module into memory.

When a module is loaded into memory, it can be loaded into the following three ways:

1. Load absolute way

When a computer system is small, and only a single channel program run time , it is entirely possible to know what the position of the program will reside in memory. At this load can be absolute mode.

After a user program compiled object code will produce an absolute address. After the load module is loaded into memory, since the logical addresses and physical addresses in the program and data are the same, there is no need to change the address of the program and data.

 

Relocatable manner was charged (loaded into memory at the time of completion, the completion of loading of all addresses are physical addresses)

It may be depending on the circumstances of the load module memory to the appropriate memory location.

In multiprogramming environment, the compiler can not know after a compiled object modules should be stored at any location in memory. Thus, for a number of user programs compiled object modules are formed, which are usually from the start address of zero, other addresses are relative to the program start address calculation.

Typically, the address modification process of the target process instructions and data load process is called relocation. Because of address translation is typically loaded once when the process is completed, the changes do not occur thereafter, and therefore is called static relocation.

Relocatable load module is loaded manner can be loaded into any memory allows the position, for multiprogramming environment.

 

Dynamically loaded at runtime

Dynamic loader at runtime after the module is loaded into memory, the logical address of the module not immediately changed to a physical address, but only when the address conversion program to be actually executed, so the loaded memory All addresses are logical addresses.

 

Linker

When the target of the link module, depending on the time of the link, the link can be divided into three types:

1. static linking mode

Before the program runs, the first target module and the required library functions into a load module link will no longer open. We call this way is called pre linked statically linked manner.

Guess you like

Origin www.cnblogs.com/Virus-Faker/p/11939325.html