nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::services::runtime::Program Class Reference

Represents a compiled program ready for execution. More...

#include <program.h>

Public Member Functions

 Program (nsbaci::compiler::InstructionStream i)
 Program (nsbaci::compiler::InstructionStream i, nsbaci::types::SymbolTable s)
 Program (const Program &)=delete
Program & operator= (const Program &)=delete
 Program (Program &&)=default
Program & operator= (Program &&)=default
const nsbaci::compiler::InstructiongetInstruction (uint32_t addr) const
 Gets instruction at the given address.
size_t instructionCount () const
 Gets the total number of instructions.
nsbaci::types::Memorymemory ()
 Access to global memory.
const nsbaci::types::Memorymemory () const
const nsbaci::types::SymbolTablesymbols () const
 Access to symbol table.
void addSymbol (nsbaci::types::SymbolInfo info)
 Add a symbol to the symbol table.
int32_t readMemory (nsbaci::types::MemoryAddr addr) const
 Read a value from memory.
void writeMemory (nsbaci::types::MemoryAddr addr, int32_t value)
 Write a value to memory.
void createSemaphore (nsbaci::types::MemoryAddr addr, int32_t initialCount)
 Create a semaphore at the given address.
bool semaphoreWait (nsbaci::types::MemoryAddr addr, nsbaci::types::ThreadID threadId)
 Wait (P operation) on a semaphore.
nsbaci::types::ThreadID semaphoreSignal (nsbaci::types::MemoryAddr addr)
 Signal (V operation) on a semaphore.
bool hasSemaphore (nsbaci::types::MemoryAddr addr) const
 Check if a semaphore exists at the given address.

Detailed Description

Represents a compiled program ready for execution.

The Program class contains the instruction vector, memory tables, and other data structures needed for program execution.

Member Function Documentation

◆ addSymbol()

void nsbaci::services::runtime::Program::addSymbol ( nsbaci::types::SymbolInfo info)

Add a symbol to the symbol table.

Parameters
infoThe symbol information to add.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSemaphore()

void nsbaci::services::runtime::Program::createSemaphore ( nsbaci::types::MemoryAddr addr,
int32_t initialCount )

Create a semaphore at the given address.

Parameters
addrMemory address to associate with the semaphore.
initialCountInitial semaphore count.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstruction()

const nsbaci::compiler::Instruction & nsbaci::services::runtime::Program::getInstruction ( uint32_t addr) const

Gets instruction at the given address.

Parameters
addrThe instruction address.
Returns
Reference to the instruction.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasSemaphore()

bool nsbaci::services::runtime::Program::hasSemaphore ( nsbaci::types::MemoryAddr addr) const

Check if a semaphore exists at the given address.

Parameters
addrAddress to check.
Returns
true if semaphore exists, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ instructionCount()

size_t nsbaci::services::runtime::Program::instructionCount ( ) const

Gets the total number of instructions.

Returns
Number of instructions in the program.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ memory()

nsbaci::types::Memory & nsbaci::services::runtime::Program::memory ( )

Access to global memory.

Returns
Reference to memory.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMemory()

int32_t nsbaci::services::runtime::Program::readMemory ( nsbaci::types::MemoryAddr addr) const

Read a value from memory.

Parameters
addrMemory address to read from.
Returns
Value at the address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ semaphoreSignal()

nsbaci::types::ThreadID nsbaci::services::runtime::Program::semaphoreSignal ( nsbaci::types::MemoryAddr addr)

Signal (V operation) on a semaphore.

Parameters
addrAddress of the semaphore.
Returns
ThreadID to wake, or 0 if none waiting.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ semaphoreWait()

bool nsbaci::services::runtime::Program::semaphoreWait ( nsbaci::types::MemoryAddr addr,
nsbaci::types::ThreadID threadId )

Wait (P operation) on a semaphore.

Parameters
addrAddress of the semaphore.
threadIdThe thread attempting to wait.
Returns
true if thread can proceed, false if it must block.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ symbols()

const nsbaci::types::SymbolTable & nsbaci::services::runtime::Program::symbols ( ) const

Access to symbol table.

Returns
Const reference to symbol table.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeMemory()

void nsbaci::services::runtime::Program::writeMemory ( nsbaci::types::MemoryAddr addr,
int32_t value )

Write a value to memory.

Parameters
addrMemory address to write to.
valueValue to write.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: