S3.24.1 Count the Walks

MediumImplement22 minIcarus Verilog · serverReview the topic

Two programs take turns on one TLB. Count the table walks with a flush at every switch, and with an ID in every entry.

Hardware context: A TLB of four entries shared by two programs with a page table each, as test code, with a flush and with an ID in each entry. Managing the TLB at a context switch and after a page-table update

A TLB has four entries. A refill uses the entries in turn: 0, 1, 2, 3, and then 0 again. Program A uses its pages 1 and 2. Program B uses its pages 1 and 3. Page 1 of A and page 1 of B are different pages in different frames. In one turn, a program uses each of its two pages five times, in the order first page, second page, first page, and so on. The schedule is four turns: A, B, A, B. The TLB starts empty. A walk reads two table entries.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification

Enter counts as whole numbers. For a yes or no question, enter 1 for yes and 0 for no.

EntryYour decision
ACCESSESHow many accesses do the four turns make in all?
WALKS_FIRST_TURNHow many walks does the first turn of A need?
WALKS_WITH_FLUSHThe TLB is flushed at every switch. How many walks do the four turns need?
HITS_WITH_FLUSHAnd how many of the 40 accesses hit?
WALKS_WITH_IDSNow each entry carries the ID of its program, and nothing is flushed. How many walks?
TABLE_READS_SAVEDHow many reads of table entries do the IDs save, against the flush?
STALE_HITNo flush and no IDs: A runs, then B uses its page 1. Does B get the frame of A? Enter 1 or 0.
TAG_BITS_WITH_IDA page number has 20 bits and an ID has 4 bits. How many bits does a lookup compare in each entry?
PROGRAMS_WITH_4_BITSHow many address spaces can an ID of 4 bits tell apart?
WALKS_THREE_PROGRAMSWith IDs, a program C with pages 1 and 4 joins. The schedule is A, B, C, A. How many walks?
WALKS_FLUSH_FOR_TURNSA and B take TURNS turns in all, one after the other, starting with A. The TLB is flushed at every switch. Give the number of walks.

Examples

Example 1

ACCESSES
Input
How many accesses do the four turns make in all?
Output
matches = 1

Four turns of two pages, five times each: 40.

Example 2

WALKS FIRST TURN
Input
How many walks does the first turn of A need?
Output
matches = 1

Each of its two pages misses once, at its first use.

Example 3

WALKS WITH FLUSH
Input
The TLB is flushed at every switch. How many walks do the four turns need?
Output
matches = 1

Every turn starts with an empty TLB and walks for its two pages: 4 times 2.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For WALKS_FLUSH_FOR_TURNS, enter a constant expression using TURNS. Only this entry changes with the parameter. The supported integer range is 2 through 100, inclusive.

Hints

Hint 1

Follow one turn first: which accesses miss, and which entries are filled?

Hint 2

Decide what the TLB holds after the switch: nothing, or everything with its ID.

Hint 3

Keep a list of the four entries and of the one that is filled next.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

11 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 problem on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

ACCESSES

Input
How many accesses do the four turns make in all?
Expected output
matches = 1

Four turns of two pages, five times each: 40.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus Verilog · server