Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 3500 Introduction to Operating Systems Memory Management: Part 1 Dr. Xiao Qin Auburn University Slides.

Similar presentations


Presentation on theme: "COMP 3500 Introduction to Operating Systems Memory Management: Part 1 Dr. Xiao Qin Auburn University Slides."— Presentation transcript:

1 COMP 3500 Introduction to Operating Systems Memory Management: Part 1 Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin xqin@auburn.edu Slides are adopted and modified from Drs. Stallings, Silberschatz, Galvin, Gagne, Nutt

2 The External View of the Memory Manager Slide courtesy of Dr. Gary Nutt 2

3 The Basic Memory Hierarchy CPU Registers Primary Memory (Executable Memory) e.g. RAM Secondary Memory e.g. Disk or Tape More Frequently Used Information Less Frequently Used Information Slide courtesy of Dr. Gary Nutt 3 Larger storage Q1: Capacity? Faster access Speed?

4 LBNL IT Backup Robotic Tape Libraries URL: servback.lbl.gov/backups/equipment/robots.html 4

5 Memory Management Requirements Q2: Can you list two functionalities? Relocation Protection Sharing Logical organization Physical organization

6 Address Space vs. Primary Memory 6 Mapped to object other than memory Process Address Space Hardware Primary Memory

7 7 Load time: Allocate primary memory Adjust addresses in address space Copy address space from secondary to primary memory Loader Process address space Primary memory Compile time: Translate elements Source code Source code C Reloc Object code Reloc Object code Link Edit Link Edit Library code Library code Other objects Other objects Secondary memory Link time: Combine elements Creating an Executable Program

8 A Sample Code Segment... static int gVar;... int proc_a(int arg){... gVar = 7; put_record(gVar);... }

9 The Relocatable Object Module Code Segment Relative AddressGenerated Code 0000...... 0008entryproc_a... 0220load=7, R1 0224storeR1, 0036 0228push0036 0232call ‘ put_record ’... 0400External reference table... 0404 ‘ put_record ’ 0232... 0500External definition table... 0540 ‘ proc_a ’ 0008... 0600(symbol table)... 0799(last location in the code segment) Data Segment Relative AddressGenerated variable space... 0036[Space for gVar variable]... 0049(last location in the data segment)

10 The Absolute Program After the link editor combines relocatable modules Code Segment Relative AddressGenerated Code 0000(Other modules)... 1008entryproc_a... 1220load=7, R1 1224storeR1, 0136 1228push1036 1232call2334... 1399(End of proc_a)... (Other modules) 2334entryput_record... 2670(optional symbol table)... 2999(last location in the code segment) Data Segment Relative AddressGenerated variable space... 0136[Space for gVar variable]... 1000(last location in the data segment) Q3: What is the difference Between the absolute program and the relocatable object module?

11 The Program Loaded at Location 4000 Relative AddressGenerated Code 0000(Other process ’ s programs) 4000(Other modules)... 5008entryproc_a... 5036[Space for gVar variable]... 5220load=7, R1 5224storeR1, 7136 5228push5036 5232call6334... 5399(End of proc_a)... (Other modules) 6334entryput_record... 6670(optional symbol table)... 6999(last location in the code segment) 7000(first location in the data segment)... 7136[Space for gVar variable]... 8000(Other process ’ s programs)

12 Dynamic Relocation using a Relocation Register Hardware device that maps virtual to physical address The value in the relocation register is added to every address generated by a user process at the time it is sent to memory The user program deals with logical addresses; it never sees the real physical addresses

13 Static Memory Partitioning  Used in several variations in some now- obsolete operating systems  Does not involve virtual memory 13 Operating System Process 3 Process 0 Process 2 Process 1 Unused In Use Issue: Need a mechanism/policy for loading p i ’s address space into primary memory pipi

14 14

15 Memory Management Terms 15 Frame vs. Page vs. Segment

16 Static Memory Allocation (Cont.) Hole – block of available memory; holes of various size are scattered throughout memory When a process arrives, it is allocated memory from a hole large enough to accommodate it Operating system maintains information about: a) allocated partitions b) free partitions (hole) OS process 5 process 8 process 2 OS process 5 process 2 OS process 5 process 2 OS process 5 process 9 process 2 process 9 process 10

17 Fixed-Partition Memory Mechanism Operating System Region 3 Region 2 Region 1 Region 0N0N0 N1N1 N2N2 N3N3 pipi p i needs n i units nini

18 Fixed-Partition Memory Best-Fit Operating System Region 3 Region 2 Region 1 Region 0N0N0 N1N1 N2N2 N3N3 pipi Internal Fragmentation Loader must adjust every address in the absolute module when placed in memory Q4: Pros and Cons?

19 Fixed-Partition Memory Worst-Fit Operating System Region 3 Region 2 Region 1 Region 0N0N0 N1N1 N2N2 N3N3 pipi Q5: Pros and Cons?

20 Fixed-Partition Memory First-Fit Operating System Region 3 Region 2 Region 1 Region 0N0N0 N1N1 N2N2 N3N3 pipi Q6: Pros and Cons?

21 Fixed-Partition Memory Next-Fit Operating System Region 3 Region 2 Region 1 Region 0N0N0 N1N1 N2N2 N3N3 pipi P i+1 Fixed-Partition strategies were used in batch multiprogramming systems (why?) Not good for timesharing systems Q7: Pros and Cons?

22 Disadvantages A program may be too big to fit in a partition – program needs to be designed with the use of overlays Main memory utilization is inefficient – any program, regardless of size, occupies an entire partition – internal fragmentation wasted space due to the block of data loaded being smaller than the partition 22

23 Summary Memory Management Requirements Dynamic Relocation using a Relocation Register Static Memory Partitioning Frame vs. Page vs. Segment 23


Download ppt "COMP 3500 Introduction to Operating Systems Memory Management: Part 1 Dr. Xiao Qin Auburn University Slides."

Similar presentations


Ads by Google