Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

virtualMachine Class Reference

a basic virtual machine with multi-threaded proccesses More...

#include <virtualMachine.h>

Collaboration diagram for virtualMachine:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 virtualMachine ()
 ~virtualMachine ()
instruction addInstruction (instructionPtr instrPtr)
 add an instruction

bool replaceInstruction (instruction instr, instructionPtr instrPtr)
 replace the specified instruction with a instruction

uInt getNumInstructions ()
 get the current number of instructions

processId run (program &prog)
 run the specified program and return the id of the process

void kill (processId pid)
 kill the specified process

processgetProcess (processId pid)
 get a pointer to the specified process

uInt getNumProcesses ()
 get the number of processes being executed

void setNumUsedCycles (float num)
 set the number of steps per update

bool activeProcesses ()
 test if there are still active processes

void step ()
 step the virtual machine

void update (float deltaT)
 update the virtual machine


Protected Member Functions

virtual bool canBeExecuted (process &proc)
 test if the specified process can be executed

virtual bool shouldBeTerminated (process &proc)
 test if the process should be terminated

virtual void kill (process &proc)
 kills the specified process


Protected Attributes

std::vector< process * > m_pProcesses
 vector of allocated processes

uInt m_numProcesses
 number of running processes

idGen< recycleReleasedIds,
noWrapAround
m_processIdGen
float m_usedCycles
uInt m_idleCnt
bool m_activeProcesses

Detailed Description

a basic virtual machine with multi-threaded proccesses

Definition at line 19 of file virtualMachine.h.


Constructor & Destructor Documentation

virtualMachine::virtualMachine  )  [inline]
 

Definition at line 23 of file virtualMachine.h.

References m_activeProcesses, m_idleCnt, m_numProcesses, and m_usedCycles.

virtualMachine::~virtualMachine  ) 
 

Definition at line 6 of file virtualMachine.cpp.

References m_pProcesses.


Member Function Documentation

bool virtualMachine::activeProcesses  )  [inline]
 

test if there are still active processes

Definition at line 58 of file virtualMachine.h.

References m_activeProcesses.

instruction virtualMachine::addInstruction instructionPtr  instrPtr  ) 
 

add an instruction

Definition at line 17 of file virtualMachine.cpp.

References addInstruction(), instruction, and instructionPtr.

Referenced by addInstruction().

bool virtualMachine::canBeExecuted process proc  )  [protected, virtual]
 

test if the specified process can be executed

Definition at line 167 of file virtualMachine.cpp.

References canBeExecuted(), and process::isTerminated().

Referenced by canBeExecuted(), and step().

uInt virtualMachine::getNumInstructions  )  [inline]
 

get the current number of instructions

Definition at line 37 of file virtualMachine.h.

References uInt.

uInt virtualMachine::getNumProcesses  )  [inline]
 

get the number of processes being executed

Definition at line 49 of file virtualMachine.h.

References m_numProcesses, and uInt.

process * virtualMachine::getProcess processId  pid  ) 
 

get a pointer to the specified process

Definition at line 89 of file virtualMachine.cpp.

References getProcess(), and m_pProcesses.

Referenced by getProcess().

void virtualMachine::kill process proc  )  [protected, virtual]
 

kills the specified process

Definition at line 179 of file virtualMachine.cpp.

References process::clean(), kill(), process::m_id, m_numProcesses, m_processIdGen, and recycleReleasedIds::releaseId().

void virtualMachine::kill processId  pid  ) 
 

kill the specified process

Definition at line 78 of file virtualMachine.cpp.

References kill(), and m_pProcesses.

Referenced by kill(), and step().

bool virtualMachine::replaceInstruction instruction  instr,
instructionPtr  instrPtr
 

replace the specified instruction with a instruction

Definition at line 24 of file virtualMachine.cpp.

References replaceInstruction(), and WARN.

Referenced by replaceInstruction().

processId virtualMachine::run program prog  ) 
 

run the specified program and return the id of the process

Definition at line 44 of file virtualMachine.cpp.

References idGen< recycleReleasedIds, noWrapAround >::getId(), m_numProcesses, m_pProcesses, process::m_pProgram, m_processIdGen, processId, run(), process::spawnThread(), uInt, and WARN.

Referenced by run().

void virtualMachine::setNumUsedCycles float  num  ) 
 

set the number of steps per update

Definition at line 146 of file virtualMachine.cpp.

References m_usedCycles, and setNumUsedCycles().

Referenced by setNumUsedCycles().

bool virtualMachine::shouldBeTerminated process proc  )  [protected, virtual]
 

test if the process should be terminated

Definition at line 173 of file virtualMachine.cpp.

References process::m_id, and shouldBeTerminated().

Referenced by shouldBeTerminated(), and step().

void virtualMachine::step  ) 
 

step the virtual machine

Definition at line 102 of file virtualMachine.cpp.

References canBeExecuted(), instruction, thread::isTerminated(), kill(), m_activeProcesses, m_pProcesses, processId, shouldBeTerminated(), and threadId.

Referenced by update().

void virtualMachine::update float  deltaT  ) 
 

update the virtual machine

Definition at line 153 of file virtualMachine.cpp.

References m_idleCnt, m_usedCycles, step(), and update().

Referenced by update().


Member Data Documentation

bool virtualMachine::m_activeProcesses [protected]
 

whether there were active processes during the last step

Definition at line 98 of file virtualMachine.h.

Referenced by activeProcesses(), step(), and virtualMachine().

uInt virtualMachine::m_idleCnt [protected]
 

Definition at line 94 of file virtualMachine.h.

Referenced by update(), and virtualMachine().

uInt virtualMachine::m_numProcesses [protected]
 

number of running processes

Definition at line 87 of file virtualMachine.h.

Referenced by getNumProcesses(), kill(), run(), and virtualMachine().

std::vector<process*> virtualMachine::m_pProcesses [protected]
 

vector of allocated processes

Definition at line 84 of file virtualMachine.h.

Referenced by getProcess(), kill(), run(), step(), and ~virtualMachine().

idGen<recycleReleasedIds, noWrapAround> virtualMachine::m_processIdGen [protected]
 

used to generate proccess ids and keep track of terminated processes

Definition at line 91 of file virtualMachine.h.

Referenced by kill(), and run().

float virtualMachine::m_usedCycles [protected]
 

Definition at line 93 of file virtualMachine.h.

Referenced by setNumUsedCycles(), update(), and virtualMachine().


The documentation for this class was generated from the following files:
Generated on Sun Mar 6 22:12:36 2005 for virtualMachine03 by doxygen 1.3.7