Presentation is loading. Please wait.

Presentation is loading. Please wait.

II’nd PART OPERATING SISTEMS LECTURE 10 MEMORY MANAGEMENT Ştefan Stăncescu 1.

Similar presentations


Presentation on theme: "II’nd PART OPERATING SISTEMS LECTURE 10 MEMORY MANAGEMENT Ştefan Stăncescu 1."— Presentation transcript:

1 II’nd PART OPERATING SISTEMS LECTURE 10 MEMORY MANAGEMENT Ştefan Stăncescu 1

2 MEMORY MANEGEMENT 2 Main Memory – cf. von Neumann arh. (nonremanent – fast ) : Cell row where info are deposed, modified, kept Code & data space where programs act as processes Memory management : Free/allocated memory space management Allocate/free memory spaces to processes in run Swap => MP – disk transfer Transfers between hierarchical levels of memories Virtual memory management – page fault mechanisms

3 MEMORY MANEGEMENT 3 No MM MSDOS – Only one user program in memory – cooperativ SO – one program after each, in batch processing Al resources available – no security Multiprocessing only with collaborative threads in time sharing UC - - embedded systems User programs OS User programs DD (I/O) User programs OS

4 MEMORY MANEGEMENT 4 Fixed memory partitions management Time shared UC for separate processes –allocation at boot Each process runs only in previously fixed space In each memory fixed partition Batch processing management in each partition Process queue management at each fixed partition Process memory space allocation at fixed partition accordingly with partition resources (space)  Empty partitions with satisfied queues and a lot of partitions with processes in wait for memory space => only one queue for all but inappropriate space allocation Partitia 1 Partitia 2 Partitia 3 Partitia 4 Partitia 5

5 MEMORY MANEGEMENT 5 Swap memory – variable “partitions” Disk (external memory) resident programs when a process run is needed by process scheduler program is loaded and run from disc in MM with instant space required by process when a process run is ended, all data needed are saved on disk and memory space in MM is released Disc  main memory = swap  Space allocation/released accounted  Free space compaction and management Partitia 1 Partitia 2 Partitia 3 Partitia 4 Partitia n

6 MEMORY MANEGEMENT Variable memory partitions – swap => Free space management Process memory space allocation optimized PROCES B PROCES A PROCES C PROCES B PROCES A PROCES D 3 PROCES B PROCES A PROCES D Prtitia 3 PROCES E PROCES A PROCES F PROCES D PROCES E PROCES A

7 MEMORY MANEGEMENT 7 Rule 50% N processes  N/2 holes 1 process => up 50% probability hole/process down 50% probability hole/process  Total 2 processes for 1 hole

8 MEMORY MANEGEMENT 8 Unused memory rule (N/2) * kS = M-NS M=NS(1+k/2) f=% unused space in memory f=(N/2) * (kS /M)// no. holes * hole dim/ all memory dim. f=NkS/2M=NkS/2(NS*(1+k/2))// with M calculated before  f=k/(2+k)// f is dependent only of k Ex: k=1/2 => f=(1/2)/(2+1/2)=1/5=20% k=1/4 => f=11% S = medium process dim kS = medium hole dim M = all memory dim N = no. processes n/2= no. holes (50% rule)

9 MEMORY MANEGEMENT 9 Process allocation in holes with holes list 1.First fit => first hole in list sufficient for process => fast 2.Next fit => first fit in rest list => little worse as first fit 3.Best fit => most near dim in list => worsest 4.Worst fit => anti best fit, small process in greater hole All alg are slow, by hole list analysis time improvements => sorting, separate lists, etc. 5.Quick fit => separate hole lists of fixed dims =>Problem=> merging little holes – working with big holes

10 MEMORY MANEGEMENT 10 Modele in gestiunea de spatii de memorie Harta de biti -Bitmap

11 MEMORY MANEGEMENT 11 Modele in gestiunea de spatii de memorie Liste inlantuite:

12 MEMORY MANEGEMENT 12 Modele in gestiunea de spatii de memorie Modificari la liste inlantuite AXB AB XB A B AX X

13 MEMORY MANEGEMENT 13 Modele in gestiunea de spatii de memorie Buddy sistem 32k64k AA AAB AABCC BCC BDCC DCC CC

14 MEMORY MANEGEMENT 14 Page Replacement Algorithms at Page Faults Optimal Page Replacement Algorithm Not Recently Used – NRU First In First Out – FIFO Second chance Clock Least Recently Used - LRU Not Frequently Used - NFU Not Frequently Used – NFU w/Aging Working set - WS WS w/Clock

15 MEMORY MANEGEMENT 15 Page Replacement Algorithms at Page Faults Optimal Page Replacement Algorithm Ideal one, not realizable Optimality: First the program runs with fixed data Note the page demanding list Decide best replacements by keeping minimum PF (the most delayed use page will be replaced) At each PF => calculate the most delayed use page replace that one with the demanded page

16 MEMORY MANEGEMENT 16 Some HW adjacent each physical page w info needs in decision about page replacement. Reference-Modify HW cell memories: RM 00No referred page, w/o read/write - modify 10Recent read page, w/o write-modify 01Old read page, w/old write-modify 11 Recent read page, w/old or recent write-modify R erased at clock IT (“forget” old unnecessary reads)

17 MEMORY MANEGEMENT 17 NRU (not recently used) w/RM help in page ranking RM 00Class 3Max priority 10Class 2 01Class 1 11Class 0min priority NRU =>At PF eject at random any page from the less priority nonempty class Simple, no optimal, reasonably efficient, no big mistakes

18 MEMORY MANEGEMENT 18 FIFO (First In First Out) FIFO queue w/ index requested pages Alg: Fill the queue and reuse any pages in queue is requested After queue full – PF eject page in front (earliest in) Simple, efficient, but may eject page in current use, should be kept for next intensive work, although the page has spent much time in memory

19 MEMORY MANEGEMENT 19 FIFO Second Chance FIFO queue w/ index requested pages and RM Alg.: AT PF if (R=0) then replace //old page, unreffered else R=0//pretend to not be read, although R=1 move from front to end of FIFO queue //consider as a new loaded page go to next position (if same page found, replace, without remorse)

20 MEMORY MANEGEMENT 20 FIFO Clock Hand points to the oldest page On a page fault, follow the hand to inspect pages Apply clock second chance: if (R=1), R=0 and advance the hand if (R=0) replace page (only if all pages are R=1, second chance get first page) Long round

21 MEMORY MANEGEMENT 21 Least Recently Used LRU NR couter/register attached to each page to count accesses Alg: at each clock IT all NR are increments with R (0/1) //each NR keeps reference page rank at PF, page with smallest rank is ejected => old heavy runs are kept also! – wrong! Idea: aging = replace bold text w/ shift all NR 1 bit right add R(0/1) at left (msb position bit in NR)

22 GESTIUNE DE MEMORIE 22 Least Recently Used LRU

23 MEMORY MANEGEMENT 23 Not Frequently Used - NFU NR couter/register attached to each page And a overall process time counter Alg: At each reference overall increment time counter and transfer content to referred page NR // NR keeps page data access time stamp at PF eject the page with oldest data stamp (lowest content)

24 GESTIUNE DE MEMORIE 24 Not Frequently Used - NFU Pagina CKCK

25 GESTIUNE DE MEMORIE 25 Least Recently Used - LRU /Not Frequently Used – NFU LRU update at each access (instruction) NFU update at each IT (many instructions) a page may count a lot of references between IT’s same rank for a few or a lot of references pages w/first references between IT are at same rank as pages w/last references in interval


Download ppt "II’nd PART OPERATING SISTEMS LECTURE 10 MEMORY MANAGEMENT Ştefan Stăncescu 1."

Similar presentations


Ads by Google