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
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
Enter counts as whole numbers. For a yes or no question, enter 1 for yes and 0 for no.
| Entry | Your decision |
|---|---|
| ACCESSES | How many accesses do the four turns make in all? |
| WALKS_FIRST_TURN | How many walks does the first turn of A need? |
| WALKS_WITH_FLUSH | The TLB is flushed at every switch. How many walks do the four turns need? |
| HITS_WITH_FLUSH | And how many of the 40 accesses hit? |
| WALKS_WITH_IDS | Now each entry carries the ID of its program, and nothing is flushed. How many walks? |
| TABLE_READS_SAVED | How many reads of table entries do the IDs save, against the flush? |
| STALE_HIT | No 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_ID | A page number has 20 bits and an ID has 4 bits. How many bits does a lookup compare in each entry? |
| PROGRAMS_WITH_4_BITS | How many address spaces can an ID of 4 bits tell apart? |
| WALKS_THREE_PROGRAMS | With IDs, a program C with pages 1 and 4 joins. The schedule is A, B, C, A. How many walks? |
| WALKS_FLUSH_FOR_TURNS | A 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