[] Operating System Concepts Memory Management

A memory management

Test: basic concepts

1, the range of storage management: system memory can be divided into regions (the operating system stored in the memory, the low-end), the user area (user data and programs stored in high memory); user memory area is managed by the object storage.

  • Process space program must be placed in memory in order to be executed
  • Direct access to memory in the CPU only memory and processor registers

 

 

Binding 2, instructions and data to memory addresses three different stages

  • Compile time
    • If the memory address location is known, absolute code can be generated; if the start position is changed, the need to recompile the code.
  • Load time
    • If the memory location is not known at compile time, it must generate relocatable code.
    • Such as static relocation program
  • Run-time
    • If the process can be moved in memory at execution time, the address is bound to be delayed until run time. It requires hardware support for address mapping, such as base register and limit long-register.
    • Such as dynamic relocation program

 

3, program loader

  • Logical address: CPU generated addresses are called logical addresses, i.e., virtual addresses. The set of all addresses generated by the program called "logical address space"
  • Physical address space: a set of physical addresses corresponding to logical addresses harmony. Physical address = base address register contents of logical address
  • Address translation: the establishment of relations of virtual addresses and memory addresses
  • Address relocation: the program converts the logical address into a physical address
    • Static Relocation - program into memory when the assembly procedure is completed . Complete address translation prior to program execution. + = The physical address logical address of the program starting address in memory.
      • advantage
        • Easy to implement, does not require hardware support
      • Shortcoming
        • After the relocation program address will not be moved, and therefore can not re-allocate memory, it is not conducive to the effective use of memory
        • It must occupy contiguous memory space, which is difficult to achieve sharing programs and data.
    • Dynamic relocation - address conversion work during program execution dynamic address translation mechanism is implemented by the hardware address translation. + = The physical address logical address relocation register contents.
      • advantage
        • It can be non-contiguous allocation of memory
          • For each block dispersed reunification process, as long as the first address in the memory block is stored in a different uniform base register, you can get the right memory addresses by the address converted by the converter freedom.
        • Dynamic relocation provides the basis for virtual storage
          • Dynamic positioning is not required prior to re-execution for all operations to allocate memory, regardless of which can be dynamically allocated memory
        • Conducive to sharing program segment
      • Shortcoming
        • The need for additional hardware support
        • The implementation of storage management algorithm is also more complicated
  • Protection memory: address and each address register for the program generated by the CPU hardware comparing completed

 

Linker

  • Static & Dynamic Link Link
    • Dynamic Link
      • During the assembling operation of the main program
    • Static links
      • An executable file when done
      • Spend time, waste of space

 

4, memory expansion method

  • Switching technology
    • Middle scheduling scheduling hierarchy
  • Covering technology
    • After breaking the limit all the information a program must be loaded into storage in order to run

 

4.5, debris

  • Internal fragmentation
    • It has been allocated memory space larger than the memory space required
  • External fragmentation
    • It has not been dispensed, but because of too small and can not be assigned to the new application process memory space free block

5, memory allocation

  • Continuous distribution (single channel programming environment)
    • A single continuous distribution
      • Static allocation: The process Once in memory, after which he would have to wait until the end of the release
      • Single: memory, leaving only a job.
      • Continuous operation is stored in memory
      • Advantages: The method is simple and easy to implement
      • Disadvantages: only applies to single-channel program
    • Fixed allocation zone (zoning laws) - internal fragmentation
      • Data structures: partition specification table
      • Advantages: simple management, low overhead
      • Disadvantages:
        • Inflexible, large programs may not read
        • Low utilization rate of waste, large internal fragmentation
    • Dynamic allocation area (partition method) - external fragmentation
      • data structure:
        • Partition specification table
        • Available Partition Table
          • Advantages: management process is relatively simple
          • Disadvantages: difficult to determine the size of the table; to take up some memory available tables
        • Available partition free chain
          • Pros: without taking up additional memory
          • Disadvantages: difficulty to find than the available tables
      • The first adaptation algorithm
        • Are arranged in ascending order starting address
        • advantage
          • Simple arithmetic
          • Easily meet the space needs of large operations
        • Shortcoming
          • There are a waste of space debris
      • Best Fit
        • Formed in the partition size increments
        • advantage
          • First with a small storage space for the large storage space for large operations
        • Shortcoming
          • Every time to re-adjust the available tables / free chain free zone in accordance with the size, complexity of the algorithm; leave not take advantage of small space debris caused by waste
      • The worst adaptation
        • Forming a partition in decreasing capacity mode
        • advantage
          • Avoid leaving small fragments can not take advantage of the resulting waste of space, leaving debris least w
        • Shortcoming
          • Every time to re-adjust the available tables / free chain free area in accordance with the size, complexity algorithm
      • Tightening solve fragmentation problems
        • Dynamically moving memory contents, so that all the free region merging

 

  • A non-continuous distribution (multiprogramming environment)

|

| Try to solve the debris, to avoid the continuous distribution

|

  • Page management
    • There are internal fragmentation
    • Page physical address mapping logic to form
    • advantage
      • Distribution and recovery simple
      • High memory usage
      • No external fragmentation
    • Shortcoming
      • Share weak, you need a static connection

|

| User needs, share & protection

|

  • Management segment - segment request - segment table
    • advantage
      • User-friendly programming
      • Easy to share
      • Dynamically connected
      • Dynamic growth of the application can be processed when the data
    • Shortcoming
      • More hardware support
      • There are external fragmentation, defragment large overhead
      • Allow the difficulty of bringing dynamic growth & cost
      • The length of each segment is limited by the available memory size of the region

|

| Both system and user

|

  • Page management section - page request segments binding - segment table page table +
    • Instruction or data memory access once, at least three times more memory to be accessed
      • First obtained from the segment table segment table address register to access a segment table page table address corresponding to thereby remove the segment
      • Second visit to the page table to get access to all physical addresses
      • The third attempt to get access to the required physical unit
    • TLB address translation by improving speed
    • advantage:
      • No external fragmentation
      • High memory usage
      • Recycling simple assignment
      • User-friendly programming
      • Easy to share
      • Dynamically connected
      • Dynamic growth of data when the application can handle
    • Shortcoming
      • Management software adds complexity and cost increases
      • Required hardware and also increase the amount of memory
      • If Lenovo register by way of increased CPU speed access memory, speed of execution will be greatly reduced

 

Dynamic partitioning comparison algorithm

Retrieval speed : the first algorithm to adapt the best to the best and the worst sort by free partition size

Recycling process : first to adapt the best algorithm, because the best and worst to re-adjust the position of the empty first partition

Free area use : to find the best fit of the free zone is the best, but too much memory fragmentation, affecting memory usage, and the worst memory fragmentation algorithm to adapt to a minimum, but more memory allocation request process may fail.

 

Comparison of Segment Management & page management of

  • Segment is a logical unit of information, he is divided according to user's needs; physical units of page information, the management system is to facilitate division. It is transparent to the user.
  • Page size is fixed, determined by the system. The segment size is not fixed, it is determined by its complete functionality.
  • Stage provided to the user address space is two, p-type that is provided to the user address space, which is the offset within the page and Ye machine hardware features
  • Since the segment is a logical unit of information, thereby facilitating the storage and protection of shared information. Protect and share page is also limited.

 

Second, the virtual memory

 

1, test: replacement algorithm big question

Test method: for a particular memory reference sequence , run an algorithm, and calculate the number of page faults

 

Page replacement algorithm

  • FIFO algorithm replacement pages remain in memory inside the longest
    • Not to stack algorithm, there is an exception Belady
    • Increase the number of pages, the error rate may increase
  • LRU replacement of the oldest memory page has not been accessed
    • Stack algorithm, there is no abnormal Belady
  • OPT optimal page replacement algorithm: the page is displaced in the farthest future was only accessible
    • Stack algorithm, there is no abnormal Belayed
  • Approximate LRU: using the permutation bit flag
  • Global replacement algorithm
    • Selected from the set of all frames of a replacement frame
    • Disadvantages: page fault rate can not control the process
  • Partial replacement algorithm
    • From his assignment frame a selected
    • Cons: You can not use other processes not commonly used memory space

 

Page fault rate calculation:

The total number of visits to set up operations at runtime Ji successful visits to S, unsuccessful visits to F, A is

Then the job execution Ji page fault rate f = F / A, A = S + F

 

2, kernel memory allocation algorithm

  • User mode process - get the free list
  • Kernel memory - get the free pool

Kernel process two methods of memory management

  • Buddy system: fragmentation
    • Dispensed from a fixed physical size of a continuous segment
    • 2 using the power of the size of the allocated
  • Slab allocation: no debris
    • Of one or more physically contiguous pages composition

 

 

Guess you like

Origin blog.csdn.net/sinat_39763590/article/details/93157169