Paging Flashcards

1
Q

Paging

A

Von Neumann: sequential nature, locality dependent

CPU doesn’t need whole memory allocation, just needs pages

Logical addr space of process can be noncontiguous

Physical memory allocated to process when phys memory available

Physical memory - frames (fixed size blocks, power of 2, 512 bytes to 8,192 bytes

Logical memory - pages, same size as frames but there are usually more frames than pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Paging mechanics

A
  1. Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8,192 bytes)
  2. Divide logical memory into blocks of same size called pages
  3. Keep track of all free frames
  4. To run a program of size n pages, need to find n free frames and load program
  5. Set up a page table to translate logical to physical addresses
  6. Internal fragmentation may occur
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Paging Address Translation Scheme

A

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

Page number p —— Page offset d

where p = m-n d = n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

How many page tables does a process have

A

One

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Page conversion logical to physical

A

CPU generates logical address (page)

Physical address is frame

One page per process

In general less frames than pages

Offset from top of page to where instruction is

Offset = displacement

Logical may be page, offset; physical frame, displacement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Calculate how much memory needs to be allocated for page tables for 100 processes

4k memory, 32 byte machine

A

n = 2^32/2^12 (32 bytes 2^32 addr)

= 1 M pages (4 k = 2^12)

1M * 8 bytes * 100 proc = 800M

Can’t fit in CPU, must be in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

2 MA problem

A

2 memory accesses: must go to memory 2x for each instruction (in contiguous memory, only 1)

  1. search for page table, get frame
  2. memory access delay to go to frame and get instruction

so there’s page table delay to get the frame # and memory access delay to get data/instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

2 MA versus CPU speed - why do we need a cache

MA = 100 ns, CPU speed 10 ns

A

MA = 100 ns * 2 access = 200ns

CPU speed 10 ns

10 ns work, wait 190 ns for page – need cache

Cache registers run at same speed as CPU (registers and CPU have same clock) see diagram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

TLB

A

TLB translation look aside buffer

Special fast hardware cache

Also called AM associative memory

TLB is on CPU chip; made of registers, as fast as CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

EAT with 20% TLB hit rate

A

0.80 * 100 ns + 0.2 * 200 ns = 120 ns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Virtual memory definition, why needed

A

Separation of user logical memory from physical memory

Needs:

  1. physical memory imited
  2. Multiprocessing - every prgm requires address space
  3. program size may not fit in physical memory - each process has its own page table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Demand paging

A

pages in memory only as required (if 100 pages, each 4k, need 4k*100: but actually don’t need all 100 pages at a time

consider ability to execute partially loaded program no longer constrained by limits of physical memory

VM (paging) allows address spaces to be shared by several processes

Less I/O needed

Less memory needed

Faster response

More users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

PTBR and PTLR

A

Page Table base register - points to page table which is held in main memory

Page Table length register - indicates size of page table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does TLB (AM) work

A

AM is parallel search

Address translation (p,d)

stores both page # and frame # (where page table has only frame #)

If p is in associative regiser, go to it and get frame #

Otherwise go to main memory page table and get frame #

CPU goes to TLB and memory concurrently

TLB hit - only goes to memory 1 (cancels memory request( (solves 2 memory access problem)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Memory protection

A

Associate protection bit with each frame (each entry in page table)

Valid - associated page is in process’ logical address space, and thus is a legal page

invalid - not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how is virtual memory implemented

A

demand paging and demand segmentation

14
Q

page fault

A

If there is a reference to a page, first reference to that page will trap to operating system:

page fault

Operating system looks at another table to decide:

Invalid reference - abort

or it’s Just not in memory

15
Q

Steps in handling a page fault

A
  1. load M reference, go to page table
  2. trap, it’s not there; go to OS
  3. OS says it’s in back store mem, go to back
  4. bring in page from back memory, place in free frame in physical memory
  5. reset page table, restart instruction
  6. load M
16
Q

FIFO page replacement algo for page faults

A

Pros: simple, easiest to implement

Cons: more page faults

FIFO; 3 frames

Incoming pages: 1,2,3,4,1,2,5,1,2,3,4,5

All start invalid, each new is page fault (if page is there not a fault)

Start , , ,

of faults

1 , , 1

2 , 2, 1

3 3, 2, 1

4 4, 3, 2 (page replace -shift right FIFO)

5 1, 4, 3

6 2, 1, 4

7 5, 2, 1

(next 1 & 2 come in, no faults occur)

8 3, 5, 2

9 4, 3, 5 (9 faults total)

if use 4 frames, 10 faults; more frames does notnecessaril mean less page faults

17
Q

Page replacement

A

1.Find the location of the desired page on disk

  1. Find a free frame:
    - If there is a free frame, use it
    - If there is no free frame, use a page replacement algorithm to select a victim frame
  2. Bring the desired page into the (newly) free frame; update the page and frame tables
  3. Restart the process
18
Q

3 algorithms for page replacement

A
  1. FIFO
  2. Optimal
  3. Least recently used
19
Q

Belady’s Anomaly

A

More frames, more page faults

20
Q

Optimal algorithm page replacement

A

Replace page that will not be used for longest period of time

Look forward - will not be used

Pros: results in least faults but

Cons: Very difficult; complex, long reference string

21
Q

Least recently used algo for page replacement

A

Need time stamp, sort by time stamp (complex)

Counter implementation or stack implementation

Pros: no shift register; slightly less page faults

Cons: complex, requires timestamp, not simple

22
Q

LRU example (look back)

A

same 3 frames, string 1,2,3,4,1,2,5,1,2,3,4,5

Page fault # Frames

1 1, , ,

2 1, 2, ,

3 1, 2, 3,

4 4, 2, 3 (1 out b/c least recent)

5 4, 1, 3 (swap out 2)

6 and so forth