1 / 41

Memory Management

Memory Management. Memory or Storage. Real Memory physical main memory Virtual Memory storage conceived by users. Problem of Memory Management (1). How many jobs in memory at one time programs or processes Storage amount per job same size different size.

mahola
Télécharger la présentation

Memory Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Memory Management SunMoon University

  2. Memory or Storage • Real Memory • physical main memory • Virtual Memory • storage conceived by users SunMoon University

  3. Problem of Memory Management(1) • How many jobs in memory at one time • programs or processes • Storage amount per job • same size • different size SunMoon University

  4. Problem of Memory Management(2) • Location to run a job • Fixed  absolute binding and loading • Variable  relocate binding and loading • binding • loading • linking • compiler SunMoon University

  5. 주소 번역 j int tiger; int lion; int cat; int dog; main() { L1: tiger++; lion++; goto L1; } main: mov ax, bx mov cx, dx L1: mov ax, tiger add ax mov _tiger, ax mov bx, _lion add bx mov _lion, bx goto L1 end 1011 1110 1111 1011 1110 1000 1110 1000 1110 1101 1000 1111 1101 (D) Text Load Data (A) C source program (C)binary code Stack (B) 가상 assembly program SunMoon University

  6. Instruction Cycle Address … … 104 108 … … C P U Main : … … mov a1, b1 mov a2, b2 … … P C 104 108 I R Mov a1, b1 Mov a2, b2 < Assembly file> SunMoon University

  7. Instruction Cycle j (D) (A) (B) < Memory > SunMoon University

  8. OSvs.Compilervs.Loader u Compiler Loader OS Memory Manager Kernel OS XXXX (C)binary code 적재 (C)binary code (A) C source program (B) assembly program < Memory > < H/D > 적재될 Memory 주소 XXXX가 어느곳인가? SunMoon University

  9. 적재할 메모리 주소를 알고 있는 경우 n Compiler Loader (A) (D) Compiler가 OS의 Memory 관리자로부터 메모리에 적재할 주소(ex)1000번지)를 미리 통보 받아 알고 있다. 컴파일러가 직접 메모리상의 주소를 생성 로더는 단순 적재(Absolute loader) SunMoon University < Memory >

  10. 적재할 메모리 주소를 모르는 경우1 g Compiler는 가상의 주소(ex) 0번지)에 적재된다고 가정하고 주소 생성 Loader가 적재되는 시점에 OS로부터 가용한 메모리 주소(ex)3500번지)를 통보 받는다. Loader는 새로운 주소로 바꾸고 (Relocatable Loader)적재한다. SunMoon University

  11. 적재할 메모리 주소를 모르는 경우2 g 컴파일러는 X(0번지)에서 시작하는것으로 생각하고 주소를 생성한다. 실제 주소는 X에서 3500을 더한다. X main: mov ax, bx mov cx, dx L1: mov ax, tiger add ax mov _tiger, ax mov bx, _lion add bx mov _lion, bx goto L1 end Compiler Loader 새로운 주소로 바꾼다. (A) (D) SunMoon University < Memory >

  12. Problem of Memory Management(3) • Memory Partition Method • Static (fixed) binding • Dynamic(variable) binding • Placement Method for a job • Contiguous • Noncontiguous SunMoon University

  13. Storage Hierarchy • Cache memory • Associative memory • RAM(Random Access Memory) • Hard Disk • etc. • Dfigure 7.1 SunMoon University

  14. SunMoon University

  15. Memory Management Strategies(1) • Obtaining the best possible use of main memory resources 1. Fetch Strategies 2. Placement Strategies 3. Replacement Startegies SunMoon University

  16. Fetch Strategies • Definition : • when to obtain the next piece of program or data to transfer from secondary storage to main memory • Demand Fetch • when it is referenced by a running program • Anticipatory Fetch • improve system performance SunMoon University

  17. Placement Strategies • Definition • where in main memory to place an incoming program • First-fit • Best-fit • Worst-fit SunMoon University

  18. Replacement Strategies • Definition : • which piece of program or data to displace to make room for incoming program • FiFO, LRU, … • vs.) swapping • develop to ‘paging’ or ‘segmentation’ SunMoon University

  19. Storage Allocation • Contiguous Storage Allocation • easy • Noncontiguous Storage Allocation • partition a program into several block or segment • efficient SunMoon University

  20. Single User Allocation(1) • Single user • Dfigure 7.2 • Waste resources • Size of program < size of memory • overlay • main memory 보다 큰 size의 프로그램을 실행시킨다. • Dfigure 7.3 • develop to “Virtual Memory” SunMoon University

  21. SunMoon University

  22. SunMoon University

  23. Single User Allocation(2) • Protection • protection for OS : no protection in XT, AT • boundary register • whenever program reference the main memory • supervisor call • Dfigure 7.4 SunMoon University

  24. SunMoon University

  25. Fixed Partition Multiprogramming(1) • In general, more memory than single user system • CPU utilization on a single user system • better utilization of the CPU • Dfigure 7.5 • Definition : • devide main memory into fixed size partition • each partition has a single job SunMoon University

  26. SunMoon University

  27. Fixed Partition Multiprogramming(2) • Absolute loader • Absolute translation and loading • Dfigure 7.6/7.7 • Assign the job to a special partition • Storage waste • Wait a job when the other partition are available • Easy SunMoon University

  28. SunMoon University

  29. SunMoon University

  30. Fixed Partition Multiprogramming(3) • Relocatable loader • relocatable translation and loading • assign a job to any available partition • Dfigure 7.8 • Protection in multiprogramming • Use several boundary register • Dfigure 7.9 • Fragmentation in fixed partition multiprogramming • Unused space in each partition SunMoon University

  31. SunMoon University

  32. SunMoon University

  33. Variable Partition Multiprogramming(1) • Minimize fragmentation • No fixed boundary • Contiguous allocation of each job • Partition of each job • Size of partition • No fragmentation in a partition • “hole” • 그림 7.7/7.8/7.10 SunMoon University

  34. SunMoon University

  35. SunMoon University

  36. SunMoon University

  37. Variable Partition Multiprogramming(2) • Solution of fragmentation • Coalescing holes(통합) • borders on other free storage areas • Storage Compaction(집약) • garbage collection • 그림 7.11 / 7.12 • problem • consume system resource(CPU time) • system must stop everything • Interactive , real-time , etc. • relocated once more SunMoon University

  38. SunMoon University

  39. SunMoon University

  40. Placement Strategies • Dfigure 7.14 • Best-fit • First-fit • Worst-fit SunMoon University

  41. SunMoon University

More Related