Simulation of operating system memory management (principle)

Source: Internet
Author: User

In the past, the teacher was talking about Linux memory management. She asked us to write weekly reports every week. It seems that she was dealing with us by managing graduate students. Ah, no way. People have to bow their heads under the eaves.

In fact, the teacher also urged everyone. Gradually, I found that, in fact, there is also a benefit of weekly reports that I did not pay much attention to in the past, I have gained a new understanding of an old problem, which is actually good. I am very grateful to the teacher for his painstaking efforts.

Below I will list my understanding of some problems in memory management. If you have any different opinions after reading it, please leave a message to me. I look forward to your comments or suggestions, I wrote an example of arm serial communication last time. No one left a message and I don't know why. Is there no one in the garden doing this? I doubt this...

I answered the question and answer, so this is the case. Recently, my mood has been fluctuating. Sorry. The teacher said that the most taboo for learning is that the excerpt does not specify the source, so I will explain that some of these summaries are summarized from the computer's mind. If someone tells me about it now, what should I do about plagiarism.

1.Why is memory management required?

The CPU requires two types of information: data andCodeThe data is stored in the memory. To control CPU running, the operating system must manage the memory.

2.Several difficult concepts

User space address space process space kernel space virtual memory (virtual address space)

Process space: all resources required by the process

Kernel space: space used by the kernel

Virtual Memory: each process can enter the kernel through system calls, so the kernel space is actually shared by all processes. From the process perspective, each process can have a 4 GB virtual address space (currently)

3.Memory management goals

Address protection: OneProgramCannot access another program address space

Address independence: the address issued by the program should be irrelevant to the physical and storage address.

4.Multi-channel programming Memory Management

In multi-channel programming environments, programs cannot be added to fixed memory addresses, that is, static address translation cannot be used, which requires dynamic address translation.

Virtual Address physical address

User process ------> address translator ------> physical memory

5.Address Translation Method

A program is loaded to a specific area of the memory, and the program is added to the whole area.

Physical address=Virtual Address+Start address of the region where the program is located

Multiple programs require address protection and legal access

Valid access conditions:

Starting address of the region where the program is located<=Valid address<=Starting address of the region where the program is located+Program length

Benefits of Dynamic Address Translation:

1. Flexible

2. Protect the address

3. Implement Virtual Memory

6.Memory Management Method

Fixed loading address, fixed partition, fixed partition Switch

7.Page-Based Memory Management

Memory Management Problems: limited space waste program size

Page-based memory management overcomes external fragments and increases the available space of the program

8.Advantages and disadvantages of paging systems

Advantages:

I. No external fragments are generated

Ii. Shared small addresses

Disadvantages:

      1. The page table is large and occupies space.
      2. Reduce system speed

9.Why should I change the page?

Instead of finding a new page because a page is outdated, you need to use a new page to find an outdated page as a replacement victim.

Replacement principle:

A) It is better to never access the page again.

B) Select a page that has not been modified.

10.Page ReplacementAlgorithm

1. Random Conversion

2. first-in-first-out Calculation

3. There is a replacement algorithm (determining the algorithm's merits and demerits)

4. NRU (not recent used) Algorithm

5. Lur (least recent used) Algorithm

11.Why do we propose segmented memory management?

Due to the disadvantages of the paging system

Segment management is a generalization of basic memory management, and basic memory management is a special case of segment management.

12.Advantages and disadvantages of segmentation

Advantages:

        1. Each logical unit can have a dedicated virtual address space, greatly increasing the programming space.
        2. Convenient sharing
        3. Sparse programs save a lot of space

Disadvantages:

I. Generate external fragments

Ii. All segments must be loaded to the memory.

13. Why useSegment-page memory management?

Combining segments and pages to achieve the benefits of both segments and pages, but avoiding the defects of separate segments and pages

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.