Skip to content

Latest commit

 

History

History
207 lines (149 loc) · 5.49 KB

configuration.md

File metadata and controls

207 lines (149 loc) · 5.49 KB

Configuration File

Related: Architecture · Simulation Engine


Overview

The simulator reads a UTF-8 plain-text configuration file that fully defines a simulation:

  • Memory size and minimum allocation unit
  • Pre-existing memory state at tick 0 (optional)
  • Processes to be allocated

Quick-start template

Copy this, fill in your values, and load it.

// -------------------------------------------------------
// Memory Manager Simulator — configuration template
// -------------------------------------------------------
// Separators: comma or space (both work, pick one and stick to it)
// Comments:   // anywhere — full line or inline
// -------------------------------------------------------

[config]
SIZE, 1000    // total memory in KB (required)
ALIGN, 100    // memory alignment granularity in KB (required)

// -------------------------------------------------------
// [initial] is optional.
// Remove this section entirely to start with a single
// free hole that covers all of SIZE.
//
// One entry per line:
//   <size>          → free hole
//   <ID>, <size>    → occupied block (process already in memory)
//   *               → free hole that fills remaining space to SIZE
//
// All blocks must sum to SIZE exactly (use * to avoid counting).
// -------------------------------------------------------
[initial]
100
P1, 200
P2, 200
P3, 300
100
P5, 100

// -------------------------------------------------------
// [process] is required. One process per line:
//   ID, ArrivalTick, MemoryKB, BurstTicks
// -------------------------------------------------------
[process]
P1, 1, 200, 3
P2, 1, 300, 2
P3, 2, 100, 5
P4, 3, 200, 3
P5, 4, 100, 7

Sections

The file is divided into named sections enclosed in brackets. Section names are case-insensitive.

Section Required Description
[config] Yes Memory size and allocation unit
[initial] No Pre-existing memory layout at tick 0
[process] Yes Processes to simulate

[config] must appear before any other known section. Repeating a section is a parse error. Unknown sections are silently ignored.


Minimal configuration

[config]
SIZE, 512
ALIGN, 64

[process]
P1, 0, 128, 3
  • SIZE 512 — 512 KB total memory
  • ALIGN 64 — alignment granularity is 64 KB
  • P1, 0, 128, 3 — process P1 arrives at tick 0, needs 128 KB, runs for 3 ticks

[config] section

Two directives are mandatory. Attribute names are case-insensitive.

[config]
SIZE, 1000
ALIGN, 100
Directive Description
SIZE Total size of the memory segment (KB). Must be a multiple of ALIGN.
ALIGN Alignment granularity (KB). Every block in [initial] must be a multiple of this value. Process requests don't have to be exact multiples — the engine rounds them up to the next multiple at allocation time.

Unknown attributes in [config] are ignored.


[process] section

One process per line:

<ID>, <ArrivalTime>, <Memory>, <BurstTime>
Field Type Description
ID String Unique process identifier
ArrivalTime Integer CPU cycle at which the process arrives (ticks)
Memory Integer Memory required (KB)
BurstTime Integer Uninterrupted CPU time needed (ticks)

If a process arrives at tick 1 and has a burst time of 4, it leaves memory at tick 5.

Processes are read top to bottom. If multiple processes share the same arrival tick, their allocation order follows reading order.


[initial] section

By default, tick 0 is a single free hole the size of total memory. The [initial] section lets you override this with a pre-existing memory layout.

[initial]
<size>           // free hole
<ID>, <size>     // occupied block
*                // fill remaining space with a free hole

* as a standalone entry creates a free hole that covers all remaining space up to SIZE. Use it as the last entry to avoid counting bytes by hand. The expanded hole must be at least UNIT in size.

The sum of all blocks must equal SIZE exactly, or a parse error is raised.


Comments

Allowed everywhere — as a full line or inline after any entry:

// This is a full-line comment

[config]
SIZE, 1000    // total memory in KB
UNIT, 100

[process]
P1, 0, 200, 3    // arrives immediately, needs 200 KB for 3 ticks

Separators

Accepted separators between fields: , (comma) or space. Any other character is treated as part of the token.


Parse errors

A dialog is shown when:

  1. An initial block size is not a multiple of ALIGN.
  2. SIZE is not a multiple of ALIGN.
  3. Process identifiers are not unique within their section.
  4. A field is missing from a process line.
  5. An initial state is defined but its total size ≠ SIZE.
  6. A required directive (SIZE or ALIGN) is missing.
  7. A field cannot be parsed to its expected type.
  8. A section is duplicated.
  9. A known section ([initial] or [process]) appears before [config].
  10. * in [initial] has no space left to fill.

Limits

The simulation pre-computes the entire timeline in memory. Exceeding these thresholds may cause excessive RAM usage or incorrect behavior:

Parameter Safe limit
Total processes < 200
Processes arriving at the same tick < 50
Max burst time < 25 ticks

The engine hard-caps at 150 ticks (MAX_TICKS_PER_SIMULATION).