← Back to the collection
SYSTEMS / 2021 / SYSTEMS STUDY

An address is a translation.

Virtual Memory

A command-line study of translating virtual addresses through a page table and writing their physical representations.

MEDIUM
  • Java
BUILT WITH
  • Binary I/O
  • Page tables
ACCESS

Private source · project overview

01

Follow the bits

The program reads eight-byte words, reverses their byte order, separates a page index from an offset, and looks up the frame in a fixed table. The translated addresses are formatted and written to an output file.

02

A deliberately small model

This models a fixed mapping, not a complete memory manager. The code wraps page indices modulo the table length and only retains addresses within its chosen bit width. Those choices make the scope clear: a small exercise in representation and translation.

SYSTEM SKETCH / CONCEPTUAL OVERVIEW
VIRTUAL ADDRESS
┌────────────┬─────────────┐
│ page index │   offset    │
└─────┬──────┴──────┬──────┘
      ▼             │
  PAGE TABLE        │
      │             │
      └── frame + offset ──► PHYSICAL ADDRESS
A reading of the architecture, not an application screenshot.
SYSTEM MAP / BIT TRANSLATION PIPELINE

Split the address. Translate the page. Keep the offset.

DataInputStream → checkLengthThenAdd: binary string. checkLengthThenAdd → 12-bit virtual address: accepted address. 12-bit virtual address → Fixed pageTable[7]: page index. 12-bit virtual address → Frame bits + offset: preserved offset. Fixed pageTable[7] → Frame bits + offset: frame number. Frame bits + offset → writeAddressesToFile: formatted result.12345601 / INPUTDataInputStreamreadLong() · eight bytesLong.reverseBytes()02 / REPRESENTATIONcheckLengthThenAddPad to 12 bitsDiscard wider values03 / BIT FIELDS12-bit virtual addressPage: first 5 bitsOffset: remaining 7 bits04 / LOOKUPFixed pageTable[7]page index modulo 7Frames: 2,4,1,7,3,5,605 / TRANSLATIONFrame bits + offsetConcatenate bit stringsParse physical address06 / OUTPUTwriteAddressesToFileUppercase hex textoutput/output-OS1
  1. 01 / input

    DataInputStream

    readLong() · eight bytes

    Long.reverseBytes()

    • binary string → 2. checkLengthThenAdd
  2. 02 / representation

    checkLengthThenAdd

    Pad to 12 bits

    Discard wider values

    • accepted address → 3. 12-bit virtual address
  3. 03 / bit fields

    12-bit virtual address

    Page: first 5 bits

    Offset: remaining 7 bits

    • page index → 4. Fixed pageTable[7]
    • preserved offset → 5. Frame bits + offset
  4. 04 / lookup

    Fixed pageTable[7]

    page index modulo 7

    Frames: 2,4,1,7,3,5,6

    • frame number → 5. Frame bits + offset
  5. 05 / translation

    Frame bits + offset

    Concatenate bit strings

    Parse physical address

    • formatted result → 6. writeAddressesToFile
  6. 06 / output

    writeAddressesToFile

    Uppercase hex text

    output/output-OS1

    1. 1DataInputStream checkLengthThenAddbinary string
    2. 2checkLengthThenAdd 12-bit virtual addressaccepted address
    3. 312-bit virtual address Fixed pageTable[7]page index
    4. 412-bit virtual address Frame bits + offsetpreserved offset
    5. 5Fixed pageTable[7] Frame bits + offsetframe number
    6. 6Frame bits + offset writeAddressesToFileformatted result
    This is a fixed translation exercise. It has no page faults, backing-store fetches, replacement policy or TLB.
    Read from the implementation
    • OS1Assignment.java · readFromFile
    • checkLengthThenAdd / processAddresses
    • addToOutput / writeAddressesToFile
    CONTINUE EXPLORING

    Eight Points, Three Clusters →

    The original K-means exercise: assign eight points, move three centroids, print the iterations, repeat.

    2021
    • Python