310 likes | 413 Views
MEMORY MANAGEMENT. IM PM MM 3 SERVICES OF OS MM. MM. Keep track of all Mem locns free (F) or allocated (Al) & if al to which PR.. & how much Decide Mem allocn. Policy – which PR. should get how much Mem, when & where
E N D
MEMORY MANAGEMENT IM PM MM 3 SERVICES OF OS • MM.
MM • Keep track of all Mem locns free (F) or allocated (Al) & if al to which PR.. & how much • Decide Mem allocn. Policy – which PR. should get how much Mem, when & where • Algs to al & deallocate ( D’al) – normally – help of spl.. Hardware
MMS • Contiguous real MMS • Single contiguous MMS • Fixed partition MMS • Variable partition MMS • Non – Contiguous Real MMS • Paged MMS • Segmented MMS • Combined MMS
FOLLOW ISSUES • Relocation & Addrs translation • Protection & sharing(10 copies of wp) • Evaluation Wasted Mem Access time – OS to Mem(expln) Time complexity-Overhead of Al.. D’Al
SINGLE CONTIGUOUS M.M. At any time Only 1 PR is in mem • Taken to completion OS USER
Scheme • All RDY PR’ held on disk as executable Images – OS holds their PCB in Mem – Q • At any time – one of them runs. • When PR.. is blocked – swapped out • Next prior PR.. – swapped in • 1- PR Rng – though conceptually it is a multi programming syst
evaluation • Does not have a large wasted Mem. Fast ( no AT reqd) • Very little time complexity • Lim use – because of lack of multi-user facility
Protection & sharing • Protection bit 0 –os 1 - user
Fence reg os FENCE user
FIXED PARTITION MM Could be of diff sizes – fixed
When a partition is to be allocd.. To a PR the Follow takes place 1) Long T Sch of PM – decides – PR to Mem 2) Size from IM 3) Request to MM for partn allocn 4) With IM’ help – loads progr 5) Entry in PDT ( partition description T) 6) Allocated -7) PM sched this PR
Allocation algorithms • First fit, best fit, worst fit • Multiple Qs linked lis of PCBs in “RDY but not in Mem” Q0 –0 -2k(PRs with 0 to 2k requirement) Q1 – 2k – 5k Q2 – 5k – 8k
Sched- Round Robin priority Advantage : V Small PR.. Is not loaded in a v large Partn.. – avoids Mem wastage Disadvantage : could have a long Q for a smaller partn whereas Q for the bigger partn could be empty.
Single Q • Any algor –Priority FF, BF, WF • EXTERNAL FRAGMENTATION • INTERNAL FRAGMENTATION
SWAPPING Lifting the program form Mem & Placing it On the disk is called swapping out swapping in A blocked PR.. Is swapped out to make room for a RDY PR.. To improve CPU utilization
RELOCATION & ADDRS TRANSLATION Compiler will compile starting – 0 address virtual address or logical address – Progr may be loaded in diff addrs –physical addrss. AT must be done for all instrns except for Consts, phys I/O Port addresses & offsets which are related to PC in rel address mode.
Changes the addresses in each instrn., Before it is loaded --- earlier IBM – S/W TRANSLN.. SLOW
DYNAMIC RELOCATION Used at RUN time for each instrn… BASE REG (ex- 1000) LDA 500 Imagine a progr.. Of size 1000W the Virtual address or logical address space For this progr.. 0to 999 1000 as base Address 1000 – 1999
Phys address space When partn.. Algm ( FF, BF, etc) allocates A partn.. For a PR.. & PCB is created – Base address – stored in PCB
Only the base reg value needs to be changed before dispatching. PROTECTION Protection bits – IBM 360 / 370 4 bits Reserved – 16 user PRS… in 16 partitions
Block – 2KB. IF PR = 10KB + 1B it will Require partn with 12KB – internal fragmn.. When a PR.. Is loaded in a partn, Key of that partn.. – STORED in PSW.
4 MAJOR DRAWBACKS • Internal fragmn.. • Limits the max no. of partns… - PRS.. • Does not allow sharing easily – separate keys for shared PRS.. • H/W Malfn.. – system cannot detect it.
LIMIT REG Ensures that the virtual address is within the bounds of the PR.. Address space Ex. Progs size 1000 – Virtual address Space – 0 to 999 Limit reg would be set to 999. If it is not within the bounds, H/W – gener error – aborted.
SHARING – In fixed partn – not followed in practice EVALUATION – If 100K Partn is allocated to 60K PR.. – wasted – intern fragmn.. – If 2 parts of 20K & 40K are available & a PR of 50k has to be accom –not possible –contg – extern fragmn Access time: not very high bec of H/W Time complexity:very low bec alloc/deall routines are simple bec-fixed partns