memory management ch.8. mem. manegment methods (/strategies) continuous allocation...

33
Memory Management Memory Management Ch.8

Upload: everett-robertson

Post on 26-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Memory ManagementMemory Management

Ch.8

Page 2: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size
Page 3: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.1

Explain the difference between internal and external fragmentation.

Page 4: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.16

Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and600 KB (in order),

how would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB, and 426 KB (in order)?

Which algorithm makes the most efficient use of memory?

Page 5: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Paging Hardware (fig 8-7)

Page 6: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Paging Example (fig 8-9)

Given:

N=2 bits

M=4 bits

Page size=4 B

Physical mem. Size=32 B

# of pages= 8 pages

>>How to convert from logical address to physical address in paging???

Physical address = base address+ offset = (frame # * frame size) + offset

Page 7: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Paging Arithmetic Laws

  Page size = frame size Logical address space (/size) = 2m

Physical address space (/size) = 2x (where x is the number of bits in physical address)

Logical address space (/size) = # of pages × page size Physical address space (/size) = # of frames × frame size Page size= frame size= 2n

# of pages= 2m-n # of entries (records)in page table = # of pages (# of frames = # of pages) »» »» »» In Inverted paging ONLY

>>How to convert from logical address to physical address in paging???

Physical address = base address+ offset = (frame # * frame size) + offset

Page 8: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Consider a logical address space of 64 pages of 1024 words each, mapped onto a physical memory of 32 frames.

a. How many bits are there in the logical address?

b. How many bits are there in the physical address?

Exercise 8.14

Page 9: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Consider a logical address space of 32 pages of 1024 words each, mapped onto a physical memory of 16 frames.

a. How many bits are required in the logical address?

b. How many bits are required in the physical address?

Exercise 8.22

Page 10: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.19

Assuming a 1-KB page size What are the page numbers and offsets for the

following address references (provided as decimal numbers)

a. 2375 d. 256

b. 19366e. 16385

c. 30000

Page 11: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Address generated by CPU is divided into:

– Page number (p) – used as an index into a page table which contains base address of each page in physical memory

– Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit

– For given logical address space 2m and page size 2n

page number page offset

p d

m - n n

Address Translation Scheme (paging)Address Translation Scheme (paging)

Page 12: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Solution steps (Ex. 8.19)

1. Convert logical address: Decimal Binary

2. Split binary address to 2 parts (page # , Offset)

- offset : n digits (where 2n =page size in bytes)

- page#: m-n digits) where 2m =size in bytes of logical address space)

3. Convert offset & page# : Binary Decimal

Page 13: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Convert : Decimal Binary

21521421321221121029282726252423222120

32,76816,3848,1924,096204810245122561286432168421

Page 14: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.19- solution

Logical address

(decimal)

Logical address(binary)

Page# (6 bits )(binary)

Offset(10 bits)(binary)

Page# (decimal)

Offset(decimal)

23750000 1001 0100 01110000 1001 0100 01112327

193660100 1011 1010 01100100 1011 1010 011018934

300000111 0101 0011 00000111 0101 0011 000029304

2560000 0001 0000 00000000 0001 0000 00000256

163850100 0000 0000 00010100 0000 0000 0001161

Page size =2n =1024 B= 210 B# of bits in offset part (n) =10

Page 15: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.10

Consider a paging system with the page table stored in memory.

a. If a memory reference takes 200 nanoseconds, how long does a paged memory reference take?

b. If we add TLBs, and 75 percent of all page-table references are found in the TLBs, what is the effective memory reference time? (Assume that finding a page-table entry in the TLBs takes zero time, if the entry is there.)

Page 16: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Effective access time law

Effective access time =

∑ [probability of the case × access time of this case]

Where (∑ probability of all cases =100%)

Page 17: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Paging Hardware With TLB (fig:8-11)

Page 18: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.8

On a system with paging, a process cannot access memory that it does not own; why?

How could the operating system allow access to other memory?

Why should it or should it not?

Page 19: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.15

Consider the hierarchical paging scheme used by the VAX architecture.

How many memory operations are performed when an user program executes a memory load operation?

Page 20: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Address-Translation Scheme

Page 21: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Two-Level Page-Table Scheme

Page 22: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.6

What is the purpose of paging the page tables?

Page 23: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Consider a computer system with a 32-bit logical address and 4-KB page size . The system supports up to 512MB of physical memory. How many entries are there in each of the following:

a. A conventional single-level page table

b. An inverted page table

Exercise 8.18

Page 24: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.21

Consider the following segment table:Segment Base Length

0 219 600 1 2300 14 2 90 100 3 1327 580 4 1952 96

What are the physical addresses for the following logical addresses?a. 0,430b. 1,10c. 2,500d. 3,400e. 4,112

there is a typing error in this row in book

Page 25: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

SegmentationSegmentation>>How to convert from logical address to physical address in segmentation???

IF (offset ≤ limit) then Physical address= base address+ offsetElse Trap (address error)

Page 26: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.7

Explain why it is easier to share a reentrant module using segmentation than it is to do so when pure paging is used.

Page 27: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.17

Describe a mechanism by which one segment could belong to the address space of two different processes.

Page 28: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.11

1. Compare paging with segmentation with respect to the amount of memory required by the address translation structures in order to convert virtual addresses to physical addresses.

Page 29: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.2

Compare the main memory organization schemes of contiguous-memory allocation, pure segmentation, and pure paging with respect to the following issues:

a. external fragmentation

b. internal fragmentation

c. ability to share code across processes

Page 30: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Exercise 8.5

Consider the Intel address translation scheme shown in Figure 8.22.

a. Describe all the steps that the Intel 80386 takes in translating a logical address into a physical address.

b. What are the advantages to the operating system of hardware that provides such complicated memory translation hardware?

c. Are there any disadvantages to this address-translation system? If so, what are they? If not, why is it not used by every manufacturer?

Page 31: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Logical to Physical Address Translation in Logical to Physical Address Translation in PentiumPentium

Page 32: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Fig 8-22: Intel Pentium Segmentation

Page 33: Memory Management Ch.8. Mem. Manegment Methods (/strategies) Continuous Allocation Multiple-partition method (Fixed-partition allocation) (variable size

Pentium Paging Architecture