[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

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号