[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

转载于:https://www.cnblogs.com/manqing/p/10674353.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值