The road to soft test-you exist in my deep mind

Source: Internet
Author: User

When I was a child, I always looked forward to the Chinese New Year. I could eat a lot of delicious food during the Chinese New Year, exposing the essence of small series. Haha, the most exciting thing I was looking forward to was the lucky money. I gave a red envelope to my sister-in-law, that gave me a red envelope, and Dad would give it to their children in the same way. What our children got from it was a pure profit. Then, I had to hold my cash box and think about it, what kind of delicious food should I buy? In my small Editor's understanding, the process of accumulating old-age money is storage. In our computer, the official definition of the following storage is to save data to certain media in a reasonable, secure, and effective manner based on different application environments and ensure effective access, in general, it can contain two meanings: on the one hand, it is a physical medium for temporary or long-term data resident; on the other hand, it is a way or behavior to ensure the integrity and security of data. Storage is to combine these two aspects to provide customers with a set of data storage solutions. Today, I will summarize the storage knowledge in the operating system. First, let's take a look at the following figure. The editor will introduce the storage-related knowledge in the context of this figure, if you have different opinions, you are welcome to discuss them.

First, let's take a look at the single continuous allocation, fixed partition allocation, and variable partition allocation of Real-Time Storage Management. Let's look at a picture and compare the three:

By comparing the above content, we can easily see that only the space allocated by the variable partition is variable, and then the single continuous allocation and the allocation by the fixed partition are static, based on the names of the three distributions, we can also better understand these three concepts. Next, let's take a closer look at these three distributions:

Single continuous allocation

We can see that the entire memory area is painted as a zone. It can only load one program in the memory at a time and can only be used for a single user or a single

Task execution.

Fixed partition allocation

The same result is that the memory allocation is relatively fixed. In addition, the fixed partition allocation also has its own characteristics, that is, the memory is divided into several blocks, for example: 10 K, 12 K, 32 K; then three programs may run. When the three programs occupy the three regions, we can run them. This partition is fixed, so once a program that is larger than these regions needs to run, it will be finished. Although the total memory is enough, it cannot run, because the division is too dead.

 Variable partition allocation

For example, there are three processes, which are the same as a single continuous allocation at the beginning. Then, when a program is running, a matching space is allocated to the program, after it is used up and released, it can be combined into a blank area to return to the initial state, which is particularly flexible. We will continue to discuss the variable partition allocation method:

Best adaptation method

Select the free memory zone equal to or closest to the requirement for allocation. This method can reduce fragments, but it may also lead to more small fragments that cannot be reused. But this still has some disadvantages. How should we understand this? For example, if we have a 6 K space and allocate a 5 K space for a program to run, the remaining 1 K will not be available in general, because there are usually few 1 K programs to run, so this 1 k is the fragmentation, so when the loop is down, there will be a lot of fragmentation. However, this allocation method is relatively good.

First adaptation method

The first time is to find the first available zone. The available zone is to find the Free Zone allocated to the job with memory greater than or equal to the job requirement. The advantage is to shorten the search time.

Worst adaptation method

Select the maximum free memory zone in the master memory. For example, if I have a 5 K program to run and the maximum Free Zone in the memory is 64 K, I will allocate 64 K to 5 k programs, then the remaining 59k free zone can be used.

Loop first adaptive algorithm

Instead of allocating data from the beginning each time, the data is matched continuously. Let's draw a picture to understand:

For example, if our memory is allocated in this way, we now have a job that requires 12 K memory usage, and we can find the right one from 5 K, 10 K, 15 K in a row, when we find 15 K, we will allocate 12 K, so when we have 3 K remaining, there is just a program that needs to be allocated 3 K content to run, if we use the first adaptation method for allocation, because the first adaptation method starts from the beginning each time, we will find the 5 K region and allocate the 5 K; but if we adapt to the loop for the first time, we will be allocated consecutively, so that we can just allocate the remaining 3 K to this program.

Virtual Storage Management

Next, let's explain the management of virtual storage. The management includes page-based storage and segment-based storage. The small editor will summarize the advantages and disadvantages and the address conversion diagram, finally, we will review our knowledge points through an example combining theoretical knowledge.

Page Storage Management

Through user programs and memory blocks, user programs are divided into N pages, and page tables act as records. Next we will look at the address translation diagram:

This is our address converter. If we want to see how this works, let's look at an example and let's analyze the example to understand:

Our problem-solving process should be like this. Our logic address is 8644 (decimal), then the binary value is: 10 0001 1100 0100; we know that the page is 4 k = 2 12 power, so the address in the page is 12 digits, so the second half of a is 10 0001 1100 0100 and the last 12 digits, the value is 0001 1100 0100, so the highest two remaining are page numbers: 10, converted to 2 in decimal format, and then found that the physical block number is 8 and converted to binary 1000, therefore, the offset on the physical fast number page is combined to 1000 0001 1100 0100, which is converted to 33220 in decimal format. As long as we understand this process, the rest is the hexadecimal conversion.

Segmented Storage Organization

Starting from the user, a program is divided into several parts:

Starting from the user, we divide a program into several blocks: we have the basis of page-based storage. This is not under the partition, but the segment size is a bit large. Let's look at address translation:

The algorithm of the segmented storage method is the same as that of the storage method. We will not go into details here.

Small message: In this blog post, the editor mainly introduces the knowledge points of storage, which are analyzed from two aspects: Real-Time Storage Management and virtual storage management. The real-time storage management part is allocated in a single row, fixed partition allocation and variable partition allocation are explained. The virtual storage management is explained from page-based storage management and segment-based storage management. There are not many small series of knowledge about storage, which is easy to understand, the content of the above knowledge points is a silly understanding by myself. If you have any friends who have different understandings, you are welcome to discuss and exchange the course. The road to soft testing is not complete ......

The road to soft test-you exist in my deep mind

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.