Chapter 3 - PowerPoint PPT Presentation

chapter 3 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 3 PowerPoint Presentation
play fullscreen
1 / 39
Chapter 3
229 Views
Download Presentation
adia
Download Presentation

Chapter 3

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Chapter 3 • Memory Management II • In this chapter we continue our study of memory management techniques.

  2. I. Paged Memory Allocation • this technique still requires the entire program to load into memory, • but, not into contiguous memory. • secondary storage and primary memory are divided into equal size units • these are called page frames , for example, 512 bytes per page frame

  3. Paged Memory Allocation, continued • The Jobs to be executed are divided into the same sized units called pages • the operating system loads pages of a job into free page frames in memory

  4. Paged Memory Allocation, continued • to keep track of what's where the operating system uses tables: • The PMT= Page Memory Table lists ]ocation of each page of a job • i.e. each job has a PMT which tells what page frames its pages occupy

  5. Paged Memory Allocation, continued • The Job Table lists each job and location of its Page Memory Table • The Memory Map Table lists every memory page frame and its status • i.e. free or busy.

  6. How the OS locates a page: • To find any particular location within a program: • the operating system must use an address reference to compute a page number and offset

  7. For Example, consider this instruction Load x, 0214 • (This is an instuction which says load the contents of register X into memory location 0214.)

  8. Suppose one page = 100 bytes 214 div100 = 2 214 mod 100 = 14 • The operating system then consults the Page Memory Table to see which physical page frame page 2 is loaded at.

  9. Thus, the desired location is at location 14 relative to the beginning of that page. • Suppose, for example, page 2 is loaded at page frame 5 in memory. 5 x 100 + 14 will be the location

  10. Internal fragmentation is still a problem but only on the last page of a job. • tasks are often subdivided at physical subdivisions which don't correspond to any logical program subdivisions.

  11. II. Demand Paging • A newer variation of paging is “demand paging” which no longer requires all pages of a job to be loaded into memory at execution. • Demand Paging facilitated development of Virtual Memory

  12. Jobs are still divided into equal sized pages, • consequently, one logical module of a job may often cover one or more pages.

  13. Demand Paging continued • In Demand Paging the operating system keeps same tables except that three new fields are added to PMT: • a "page in memory” Boolean field • a "contents modified” Boolean field

  14. Demand Paging continued • a “referenced recently” Boolean field or • this may be a time-stamp field if a Boolean field is set to "t" when page is accessed - • Look at figure 3.5, p54

  15. As a job processes ……... • if a location is referenced the operating system needs to determine its page # • and it must check the Page Memory Table to see if that page is resident, • i.e., loaded in some page frame.

  16. If the page is resident then, OK, otherwise the needed page must be loaded into memory. • This implies "swapping” the page into an availab]e page frame.

  17. If none are available it must swap one out using some algorithm to decide which. • This is known as a "page fault" and • dealing with it is the responsibility of the Page Interrupt Handler.

  18. As the page swap is done the operating system must update its tables, • i.e.. Update the PMT for both affected pages and Memory Map Table.

  19. Thrashing • Frequent page swapping is called " Thrashing" . • This is a very poor use of processor's Time. • See figure 3.6 Pg. 56

  20. III. Page Replacement Policies • Page Replacement Policies have been studied extensively. Several in common use: • Longest Time Resident is a "first in first out" (FIFO) policy in which • resident pages are tracked by a queue arranged by residency time.

  21. Least Recently Used is another FIFO po]icy in which • pages are tracked by a queue arranged by the time a page was last accessed.

  22. Most Recently Used • a LIFO policy which, as its name suggests, • results in the operating system swapping the page most recently accessed,

  23. Least Frequently Used • a policy which is often very effective. • The queue is arranged by frequency of use • See Tables 3.3, 3.4, 3.5 Pages 58 - 61.

  24. IV. The Working Set Concept • As a job processes often it uses a certain set of its pages most often. • If there is enough room in memory the OS tries to keep this "working set" of pages resident • thus page faults are minimal and swapping for this job is greatly reduced.

  25. V. Segmented Memory Allocation • This method is somewhat like paging, but the units are not all of same size. • This method is based on idea that a structured program consists of (semi) independent modules which may be of varying sizes.

  26. Memory is not divided into pages as before, rather, • The operating system allocates memory in various segment sizes dynamically, as needed. • Like demand paging, jobs are not required to load totally or into contiguous memory.

  27. As a job is compiled or assembled code segments are created and numbered sequentially. • The operating system still keeps a Job Table and Memory Map table, but • It now keeps a segment table...

  28. The Segment Table for each job contains • segment numbers, • segment sizes, • memory load address, and • fields for "segment recently referenced" and "access rights", • (see figures p65).

  29. each segment is indivisible but • not all are loaded at once or in contiguous memory.

  30. As with the Dynamic Partition method • External Fragmentation can be a problem so periodic Compaction is needed. • There is no internal fragmentation since segment size is dynamic.

  31. VI. Segmented/Demand Paging • This method combines the ideas of the last two. • It tries to reduce external fragmentation by subdividing segments into pages. • In this methcd jobs are divided into segments but • pages and page frames also exist.

  32. When a segment is loaded all of its pages load into memory • but not necessarily contiguously.

  33. the operating system uses Four Tables to manage all of this information: • a Job Table, • a Memory Map Table, • a Segment Map Table for each job and • a Page Map Table for each segment. (pages of a segment are not necessarily contiguous) • See figure 3.11, page 68.

  34. This method manages memory efficiently, but it has a lot of overhead. • It eliminates external fragmentation and most internal fragmentation.

  35. VI. Virtual Memory Management • Invented by IBM, • this technique evolved from the technique of Demand Paging

  36. Virtual Memory Management gives users the impression that their jobs are loading totally and • that memory is virtually unlimited.

  37. Before Virtual Memory programmers often worked hard to squeeze code into precious memory • Programmers developed an overlay technique in which some sections of code would replace others.

  38. Virtual Memory works very well in multitasking environments. • It takes advantage of speed disparity between processor and users. • Entire jobs are sometimes swapped out between execution slices! • See pp. 71, 72 for other adventages.

  39. End of Chapter 3