0
$\begingroup$

I have a difficult time understanding hashed page tables used in virtual memory management. Here is picture of the slide that I am referring to:

Hashed page table

Flow chart

I understand that p is hashed and then the hash is checked in the page table for a match. What is elements referring to here? Is it the page table entry? What does chain mean and where is virtual page number located?

Can someobody help me understand the flow chart? Thanks

$\endgroup$
  • $\begingroup$ The element is a page table entry (tag, the PTE proper, and a pointer/reference to the next element matching that hash value). The chain is a singly linked list for handling hash conflicts. The VPN (usually compressed by exploiting the hash table indexing bits) is used as a tag and is stored with the PTE and next pointer. $\endgroup$ – Paul A. Clayton Dec 9 '17 at 11:06
0
$\begingroup$

Definitions (What's with the symbols?)

In the diagram, we have these guys:

  • Virtual Page Number (VPN): p, q
  • Page Frame Number (PFN): r
  • Offset: d
  • Hash Function: h(x)
  • Hashed Page Table with schema (key, VPN, PFN, Pointer to next entry with key) for each entry in the table

It so happens that h(p) = same_key and h(q) = same_key. There is hash collision. Both p and q are hashed to the same_key.

This is resolved by chaining the entry with VPN = q to the entry with VPN = p. Chaining means to use the Pointer field in the entry with VPN = q to point to the entry with VPN = p.

Workflow (How the system works)

Operating system (OS) grabs p from the CPU, and performs h(p) to get same_key.

OS looks up the first entry in the Hashed Page Table with key = same_key and checks p against the first entry's VPN field. It checks p against q. This is incorrect.

OS uses the Pointer in the first entry to find the second entry. It knows that the second entry has the same key = same_key, because the Page Table is constructed this way. OS checks p against the seond entry's VPN field. It checks p against p. This is correct. Bam. Kill confirmed.

OS knows that this is the correct entry it is looking for. It grabs PFN from the second entry. It grabs r. r is the correct physical frame number that corresponds to virtual page number p.

OS uses r to look for the physical frame it wants in physical memory, and looks for the exact word wanted which is offset by d within frame r in physical memory. OS grabs the contents of the word and we're done.

Source: Dave Johnson's COMP 421 (Rice University CS Dept)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.