[Research “] Operating System D3: Storage Management

1. Basic concepts of storage management

  • Logic Address: User address, numbered from zero
    • One-dimensional logical address: (Address)
    • Two-dimensional logical address strong>: (segment number: address within the segment)
  • Main memory reuse method
    • By partition : The main memory is divided into multiple fixed/variable partitions, and one program occupies one partition
    • By page frame: The main memory is divided into multiple fixed page frames. One program occupies multiple frames
  • Mode of storage management
    • Single continuous: One Two-dimensional logical address program, occupies one fixed/variable partition
    • Segment type: Two-dimensional logical address program, occupies multiple variable partitions
    • Page type: One-dimensional logical address program, occupying multiple frames
    • Segment page type: Two-dimensional logical address program, occupying multiple frames
    • li>

  • Address translation: logical address –> physical address
    • static relocation: program loading Memory conversion (early OS)
    • Dynamic relocation: CPU execution conversion, efficiency considerations require hardware help
  • Virtual memory
    • Due to the locality and sequence of the program, it can be considered that only part of the program is transferred to the main memory, and the others are adjusted as needed.
    • Facing the purpose of expanding the main memory of programmers

2. Single continuous partition storage Management

  • Single user continuous partition management: The main memory area is divided into system area and user area, using static relocation Address conversion is generally applicable to single-user single-task operating systems (DOS)
  • Fixed partition management: One program occupies one partition, and there is a main memory allocation table. Easy to generate internal fraction
  • Variable partition management: dynamically allocate memory space according to process memory requirements, easy to generate external fraction

3. Page-based storage management**

    < li>Concept:

    • The main memory is divided into page frame, and the program is divided into page.
    • Different program pages can be placed in different main memory shelves, no need to be continuous
    • The relationship between pages and page shelves is maintained by page table
    • Use Bitmap to indicate main memory allocation and de-allocation, and use Process page table to maintain the logical integrity of the process
  • Address:
    • Logical address: Page number + Unit number
    • Physical address: Page shelf number + unit number
  • Quick form:
    • Use Cache to store part of the page table
    • Same as Cache memory data, it is also an associative memory technology and has an elimination strategy. For details, see “Relearning Computers-Principles of Computer Composition”
  • < li>Page-based virtual storage

    • Page table: identification bit + main storage block number + auxiliary storage address
    • Implementation:
      • Check the page table, if the page is in memory, generate an absolute address
      • If it is not in memory, initiate a page fault interrupt
      • The OS responds to the page fault interrupt. If there is a free page shelf in the memory, the page is loaded from the auxiliary memory. Update the page table quick table
      • If there is no free page shelf, first eliminate the page, and then import it
  • Paging algorithm:
    • Same Cache and memory scheduling strategy, please refer to “Relearning Computer-Principles of Computer Composition” for details

5. Others

  • Segmental storage management: Basically not used, slightly
  • Segment page memory management: Basically not used, slightly
  • Memory management unit MMU: < ul>
  • Function: Manage the hardware control circuit of virtual memory, map virtual addresses to physical addresses, provide memory protection, and eliminate pages when necessary
  • Implementation : Use a data structure inverted page table IPT
  • share picture

PS: Many years ago, when people were still using DOS or older operating systems, the computer’s memory was still very small. Generally, calculations are performed in K units. Correspondingly, the scale of the program at that time is not large, so although the memory capacity is small, it can still accommodate the program at that time. However, with the rise of graphical interfaces and the continuous increase in user needs, the scale of applications has also expanded. Finally, a problem lies in front of programmers, that is, the application is too large to accommodate the program in memory, usually The solution is to divide the program into many fragments called overlays. Cover block 0 runs first, and at the end it will call another cover block. Although the exchange of the cover block is done by the OS, the programmer must first divide the program. This is a time-consuming and laborious task, and it is quite boring. People must find a better way to solve this problem fundamentally. Soon people found a way, which is virtual memory (virtual memory). The basic idea of ​​virtual memory is that the total size of program, data, and stack can exceed the size of physical memory. The operating system keeps the currently used part in the memory. And save the other unused parts on the disk. For example, for a 16MB program and a machine with only 4MB memory, the operating system can decide which 4M content to keep in the memory at each time through selection, and exchange program fragments between the memory and the disk when needed, so that you can This 16M program runs on a machine with only 4M memory. And this 16M program does not need to be divided by the programmer before running.

Leave a Comment

Your email address will not be published.