2. Memory management : Early systems
Memory Allocation schemes:
Single user configurations
Fixed Partitions
Dynamic Partitions
Relocatable Dynamic Partitions
3. • Main memory –temporary memory(RAM)
• Secondary memory –Permanent memory(ROM)
• Single user contiguous scheme:
• Single Contiguous Memory Allocation is a simple
memory allocation scheme,
• Requires no special hardware features. Entire available memory
is allocated to a single job.
4. • In this scheme of allocation, the main memory is divided into 2
contiguous regions.
• One portion is permanently allocated to the operating system. All the remaining
memory is available for a single job, which has to be processed. The Job actually
uses some part of the allocated memory.
• Two h/w items need:
• 1.Register to store address
• 2. Accumulator keep track of the size ,the Program being read into memory
• It doesn’t support multiprogramming or N/W, handle one job at a time.
5. • All the computer's memory, usually with, the exception of a small portion
reserved for the operating system.
• Early years computer were physically large & low memory capacity.
• If the program doesn’t fit ,either the main memory must be increased or
program must be modified.
6. • Advantage:
• 1. Simple Allocation
• 2. Entire scheme requires less memory
• 3. Easy to implement & use.
• Disadvantage:
• 1. Memory & CPU not fully Utilized
• 2. User program is being limited.
7. • It allow multiprogramming within main memory-one partition for each job.
• Each Memory partition was designed when the system power on, and to be
reconfigured when the system shut down(Restart).
• Protect job’s memory space
• Once Partition assigned to a job , no other job will assign to that partition.
• Fixed partition allocation ,protection was mandatory for each partitions.
• Joint responsibility OS –H/W.
Fixed / Static Partitions:
8. • Its better than single contiguous allocation,
because it allow several program into
main memory at the same time.
11. DYNAMIC PARTITION:
• Partitions(MM) are created dynamically.
• Dynamic partition utilizes the memory when the 1st job load , jobs are not
in same size.
• It fit into the available space based on priority. (First come – First served
bases.).
• Memory creates fragment of free memory b/w blocks called external
fragmentation.
100k
150k
200k
OS
12. Best fit vs First fit:
• Best fit:
• The best fit deals with allocating the smallest free partition which meets
the requirement of the requesting process. This algorithm first searches the
entire list of free partitions and considers the smallest hole that is adequate.
It then tries to find a hole which is close to actual process size needed.
• J1-135k 100k - waiting job
• j2-75k 150k =15free
• j3-165k 200k =35 free
• Disadvantage: upcoming job must be wait till memory to be arrange
75k
165k
75k
135k
13. First fit
• In the first fit approach is to allocate the first free partition or hole large
enough which can accommodate the process. It finishes after finding
the first suitable free partition.
• 100k - waiting job
• 150k =100free
• 200k =150 free
J1-
10k
J2-
50k
J3-
50k
J4-
50k
14. Deallocation:100k free50k called de-allocation
• Deallocation of memory by the Operating System (OS) is a way to free the
Random Access Memory (RAM) of finished processes. New processes
are allocated again. This is how the OS works
with allocation and deallocation.
• In fixed partition- when job is completed memory manager resets the
memory block free –to store another job.
• 1.when the block to be de-allocated is adjacent(3-free-busy-free) to another
free block.
• 2.when the block to be de-allocated is b/w two free block.
• 3.when the block to be de-allocated is isolated from other free block.
J1-
50k
J1-50k
50k
15. Null entry:
• the status is changed from “a null entry to free” – indicate that a
new block of memory is available.
• When the null entry found, the beginning memory location of the
terminating job is entered in the beginning address column,(1000)
• the job size is entered under the memory block size column.
16. Relocatable dynamic partitions:
• In relocatable dynamic partition, memory manager in operating system
relocates the program, that is all empty blocks are gathered to form one
single block of large memory enough to accommodate some or all of the
jobs waiting in the queue.
• Compaction(defragmentation & garbage collection)- combining all the
empty memory spaces together.
17. Compaction
• it’s not a easy task, every program memory must be reallocated, so they are
contiguous, - every address, every reference to an address within the each
program must be adjusted to new location in memory.- OS must be
differentiate ADDRESS & DATA VALUE.
• All numbers are stored in memory as binary values.
• Assembly language instruction to ADD integer 1 to I,
• Instruction like ADDI A ,1 ex: (A+1)
18. Flag:
• A flag is a value that acts as a signal for a function or process. The value of
the flag is used to determine the next step of a program.
• Flags are often binary flags, which contain a Boolean value (true or false).
However, not all flags are binary, meaning they can store a range of values.
19. After relocation & compaction – free list & busy list updated
Show block of free memory show the new location of the job
under the process
Register: used to relocate the memory
1.Bound Register- store highest/lowest memory location
2.Relocation Register-value must be added to each address
referenced in program(correct memory address)
20. It has 3 approach in relocating memory:
• One is ->100k -75% used
• Balance 25% memory wasted
• Second is: compact memory only- constant checking of entry queue
• Make jobs were waiting.
• 3rd one:
• Prescribed amount of time elapsed, if chosen time is too small , system will
spend more time on compaction on processing.
21. PAGED MEMORY ALLOCATION:
• Before job loaded into memory divided into some parts called page-in memory location its called page frames.
• Paged memory allocation – based on dividing each incoming job into pages of equal size- some OS page size is equal size of
memory Block size.
• Page can be stored in any available page frame in main memory
• Operating systems, paging is a memory management scheme -a computer stores and retrieves data from secondary storage for
use in main memory. In this scheme, the operating system retrieves data from secondary storage in same-size blocks called
pages.
• Advantage : storing program is Non-contiguous in Main memory- so its more efficiently use any page of any job
22. • Before executing a program, memory manager prepares it by:
1) Determining the number of pages in the program
2) Locating enough empty “page frames” in main memory
3) Loading all of the program’s page into them(MM).
• 1st page contains first instruction.
• Last page contains last instruction
23. • job1 divided into 4 pages: page 0,page 1, page 2, page 3,
• Total job size: 350bytes,
• page 0 - 100
• page 1 - 100
• page 2 - 100
• page 3 – 50 (few job size perfectly fill with page size)so internal
fragmentation occurs.
• Next job must be wait till job1 ends.
• If job is Larger than 1100 bytes it never fit to memory.
• It is Non-Contiguous storage.