This simulator is designed to run operating systems and threads written for the GTU-C312 CPU architecture.
make simulatorThis command will generate the bin/simulator executable file.
./bin/simulator <filename> [-D debug_mode] [-max max_instructions]<filename>: The assembly program file to execute (e.g.,programs/os.asm)-D debug_mode: Debug mode (0-3, default: 0)-max max_instructions: Maximum number of instructions (default: 50000)
Prints the entire memory contents to stderr when the CPU halts.
./bin/simulator programs/os.asm -D 0Prints the entire memory contents to stderr after each instruction execution.
./bin/simulator programs/os.asm -D 1Warning: This mode generates a large amount of output. Suitable for small programs.
Prints the entire memory contents to stderr after each instruction execution and waits for a keypress to continue.
./bin/simulator programs/os.asm -D 2Usage: Ideal for step-by-step debugging. Press ENTER after each instruction to proceed.
Prints the thread table contents to stderr after each context switch and system call.
./bin/simulator programs/os.asm -D 3This mode is most suitable for debugging thread management and scheduling.
./bin/simulator programs/os.asm./bin/simulator programs/os.asm -D 3./bin/simulator programs/os.asm -D 2 -max 100./bin/simulator programs/os.asm -D 1 -max 50 2> memory_trace.txt- General information and execution summary
- Thread SYSCALL PRN outputs
- CPU status and statistics
- Memory dumps (Debug Mode 0, 1, 2)
- Thread table contents (Debug Mode 3)
- Context switch notifications
Thread Table Base Address: 220
Format: [ID] [State] [PC] [SP] [DataBase] [InstrBase] [IC] [WakeupCount]
States: 0=READY, 1=RUNNING, 2=BLOCKED, 3=TERMINATED
Thread 0: [0] [1:RUNNING] [1000] [1999] [20] [1000] [0] [0]
Thread 1: [1] [0:READY] [3000] [3999] [2000] [3000] [0] [0]
Thread 2: [2] [0:READY] [5000] [5999] [4000] [5000] [0] [0]
Thread 3: [3] [0:READY] [7000] [7999] [6000] [7000] [0] [0]
Thread 4: [4] [0:READY] [9000] [9999] [8000] [9000] [0] [0]
Test programs included with the project:
- programs/os.asm: Main OS and 4 user threads (sorting, searching, multiplication, idle)
- tests/test_source/sort_test.asm: Only bubble sort thread
- tests/test_source/linear_search.asm: Only linear search thread
- tests/test_source/mult_by_addition.asm: Only multiplication thread
- Debug Mode 0: Fastest, only dumps at the end
- Debug Mode 1: Very slow, full memory dump for each instruction
- Debug Mode 2: Slowest, requires user interaction
- Debug Mode 3: Moderately fast, only thread table at necessary points
./bin/simulator programs/os.asm -max 10000Check memory status with Debug Mode 1 or 2.
Track thread states with Debug Mode 3.
Test with a low max instruction limit:
./bin/simulator programs/os.asm -max 1000