• [mem] Memory management


    Memory management:

    • allocate / deallocate

    • protection: no access to a process's mem space from outside the given process

    • shared mem management: (between 2 & more procs;) shared libs, shared mem segments (via shmget()), etc.

    Approaches:

    • contiguous mem allocation

    • mono-contiguous mem allocation

    • virtual memory

    With multi-programming, multiple options for managing mem:

    • (early) partitions: each partition is a block of contiguous mem

    Degree of multiprogramming:

    • how many processes could be run at once?
      • depend on: process size, partition size & mem available

    A logical address references some location within a given process address space: the os must map every logical address(generated by some compiler ? assembler) to a physical address

    Contiguous memory allocation:

    • fit the entire process address space into physical mem in one contiguous block
      • each block has: start point, LIMIT (size in bytes)
    • partitioned mem can be fixed / dynamic

    Memory Allocation Schemes

    Fixed Partitioning Scheme:

    • N * {Size} (different sizes)
    • Each process having exactly one partition
    • OS manage the mapping between used partition - proc, keep a list of the free partitions

    Dynamic Partition Scheme:

    • size of a proc ---> size of the partition
      • on-demand partitioning
    • cause memory fragmentation
    |*********|___(finished)__(fragment)_|*********| 
    
    • if a process arrives and requires more than the largest free partition, looking for defragmentation:
      • move some proc mem physical addresses upstream
      • new process on waiting

    algorithms for determine newly arrived proc placement

    • first-fit
      scan from the top until found

      • might cause more fragments
    • next fit
      scan from the end until found

      • will cause less fragments (provide larger contiguous partition upstream)
    • best-fit
      fit into the smallest possible partition

    • worst-fit
      fit into the largest possible partition

  • 相关阅读:
    C++ for(char c:s)遍历字符串||for (char c : s)和for (char& c : s)的区别
    二维数组的查找--剑指offer(C++)
    C++学习笔记之--boolalpha
    在C++中matrix.size()和matrix [0] .size()之间的区别是什么?
    C3_note
    用webpack4从零开始构建react脚手架
    php
    正则表达式基础
    DOM
    常用H5
  • 原文地址:https://www.cnblogs.com/manqing/p/10674353.html
Copyright © 2020-2023  润新知