Namespaces unified (sal+fi -> fail), Code cleanups (-> coding-style.txt), Doxygen-comments fixed.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1319 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-07 17:47:19 +00:00
parent cdd5379e19
commit b7d904140e
136 changed files with 1487 additions and 1554 deletions

View File

@ -1,11 +1,12 @@
#include "BufferCache.hpp"
#include "Event.hpp"
namespace fi {
namespace fail {
template<class T> int BufferCache<T>::add(T val) {
size_t new_size = get_count() + 1;
size_t new_last_index = get_count();
template<class T> int BufferCache<T>::add(T val)
{
size_t new_size = getCount() + 1;
size_t new_last_index = getCount();
int res = reallocate_buffer(new_size);
if (res == 0) {
@ -15,14 +16,15 @@ template<class T> int BufferCache<T>::add(T val) {
return res;
}
template<class T> int BufferCache<T>::remove(T val) {
template<class T> int BufferCache<T>::remove(T val)
{
bool do_remove = false;
for (size_t i = 0; i < get_count(); i++) {
for (size_t i = 0; i < getCount(); i++) {
if (get(i) == val) {
do_remove = true;
}
if (do_remove) {
if (i > get_count() - 1) {
if (i > getCount() - 1) {
set(i, get(i + 1));
}
}
@ -30,31 +32,34 @@ template<class T> int BufferCache<T>::remove(T val) {
int res = 0;
if (do_remove) {
size_t new_size = get_count() - 1;
size_t new_size = getCount() - 1;
res = reallocate_buffer(new_size);
}
return res;
}
template<class T> void BufferCache<T>::clear() {
set_count(0);
template<class T> void BufferCache<T>::clear()
{
setCount(0);
free(m_Buffer);
m_Buffer = NULL;
}
template<class T> int BufferCache<T>::erase(int idx) {
for (size_t i = idx; i < get_count() - 1; i++) {
template<class T> int BufferCache<T>::erase(int idx)
{
for (size_t i = idx; i < getCount() - 1; i++) {
set(i, get(i + 1));
}
size_t new_size = get_count() - 1;
size_t new_size = getCount() - 1;
if (reallocate_buffer(new_size) != 0)
return -1;
return idx;
}
template<class T> int BufferCache<T>::reallocate_buffer(size_t new_size) {
template<class T> int BufferCache<T>::reallocate_buffer(size_t new_size)
{
if (new_size == 0) {
clear();
return 0;
@ -63,12 +68,11 @@ template<class T> int BufferCache<T>::reallocate_buffer(size_t new_size) {
if (new_buffer == NULL)
return 10;
m_Buffer = static_cast<T*>(new_buffer);
set_count(new_size);
setCount(new_size);
return 0;
}
//declare whatever instances of the template
//you are going to use here:
// Declare whatever instances of the template you are going to use here:
template class BufferCache<BPEvent*>;
} /* namespace fi */
} // end-of-namespace: fail

View File

@ -1,9 +1,12 @@
#ifndef __BUFFERCACHE_HPP__
#define __BUFFERCACHE_HPP__
#ifndef __BUFFER_CACHE_HPP__
#define __BUFFER_CACHE_HPP__
#include <stdlib.h>
namespace fi {
// FIXME: (Maybe) This should be located in utils, because
// it's "Fail*-independend"...?
namespace fail {
/**
* \class BufferCache
@ -18,24 +21,24 @@ namespace fi {
template<class T> class BufferCache {
public:
BufferCache()
: m_Buffer(NULL), m_Buffer_count(0) {}
: m_Buffer(NULL), m_BufferCount(0) {}
~BufferCache() {}
/**
* Add an element to the array. The object pointed to remains untouched.
* @param val the element to add
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
int add(T val);
/**
* Remove an element from the array. The object pointed to remains untouched.
* @param val the element to remove
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
int remove(T val);
/**
* Remove an element at a specific position. The object pointed to remains untouched.
* @param val the element to remove
* @returns a pointer to the given element's successor if successful, -1 otherwise
* @return a pointer to the given element's successor if successful, -1 otherwise
*/
int erase(int i);
/**
@ -45,7 +48,7 @@ public:
/**
* Retrieve an element from the array. Should be inlined.
* @param idx the position to retrieve the element from
* @returns the element at the given position
* @return the element at the given position
*/
inline T get(size_t idx) { return m_Buffer[idx]; }
/**
@ -56,27 +59,29 @@ public:
inline void set(size_t idx, T val) { m_Buffer[idx] = val; }
/**
* Retrieves the current length of the array. Should be inlined.
* @returns the array length
* @return the array length
*/
inline size_t get_count() { return m_Buffer_count; }
inline size_t getCount() { return m_BufferCount; }
protected:
/**
* Changes the current length of the array. Should be inlined.
* @param new_count the new array length
*/
inline void set_count(size_t new_count) { m_Buffer_count = new_count; }
inline void setCount(size_t new_count) { m_BufferCount = new_count; }
/**
* Reallocates the buffer. This implementation is extremely primitive,
* but since the amount of entries is small,
* this will not be significant, hopefully. Should be inlined.
* @param new_size the new number of elements in the array
* @returns 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
* @return 0 if successful, an error code otherwise (ATM only 10 if malloc() fails)
*/
inline int reallocate_buffer(size_t new_size);
private:
// TODO: comments needed!
T *m_Buffer;
size_t m_Buffer_count;
size_t m_BufferCount;
};
} /* namespace fi */
#endif /* BUFFERCACHE_H_ */
} // end-of-namespace: fail
#endif // __BUFFER_CACHE_HPP__

View File

@ -4,9 +4,6 @@ set(SRCS
CoroutineManager.cc
Event.cc
EventList.cc
ExperimentDataQueue.cc
Signal.cc
SynchronizedExperimentDataQueue.cc
)
add_library(controller ${SRCS})

View File

@ -1,31 +1,25 @@
#ifndef __CAMPAIGN_HPP__
#define __CAMPAIGN_HPP__
// Author: Martin Hoffmann
// Date: 09.12.2011
namespace fi
{
namespace fail {
/**
* \class Campaign
*
* Basic interface for user-defined campaigns. To create a new
* campaign, derive your own class from Campaign,
* define the run method, and add it to the CampaignManager.
*/
class Campaign
{
public:
Campaign() { };
/**
* Defines the campaign.
* @return \c true if the campaign was successful, \c false otherwise
*/
virtual bool run() = 0;
class Campaign {
public:
Campaign() { };
/**
* Defines the campaign.
* @return \c true if the campaign was successful, \c false otherwise
*/
virtual bool run() = 0;
};
}
} // end-of-namespace: fail
#endif /* __CAMPAIGN_HPP__ */
#endif // __CAMPAIGN_HPP__

View File

@ -1,9 +1,7 @@
#include "CampaignManager.hpp"
namespace fail {
namespace fi
{
CampaignManager campaignmanager;
}//end-of-namespace
} // end-of-namespace: fail

View File

@ -1,91 +1,77 @@
/**
* \brief The manager for an entire campaign
*
* The CampaignManager allows a user-campaign access to all constant
* simulator information and forwards single experiments to the JobServer.
*
* \author Martin Hoffmann
*
*/
#ifndef __CAMPAIGN_MANAGER_H__
#define __CAMPAIGN_MANAGER_H__
#ifndef __CAMPAIGN_MANAGER_HPP__
#define __CAMPAIGN_MANAGER_HPP__
#include "SAL/SALInst.hpp"
#include "ExperimentData.hpp"
#include "jobserver/JobServer.hpp"
#include "controller/Campaign.hpp"
namespace fi
{
namespace fail {
/**
* \class CampaignManager
* Class manageing an FI campaign.
*
* The CampaignManager allows a user-campaign access to all constant
* simulator information and forwards single experiments to the JobServer.
*/
class CampaignManager
{
JobServer m_jobserver;
Campaign* m_currentCampaign;
public:
CampaignManager(){};
/**
* Executes a user campaign
*/
bool runCampaign(Campaign* c){
m_currentCampaign = c;
bool ret = c->run();
m_jobserver.done();
return ret;
}
/**
* Returns a const reference for acquiring constant simulator specific information.
* e.g., Registernames, to ease experiment data construction.
* The campaign description is not allowed to change the simulator
* state, as the actual simulation runs within another process (Minion)
* @return constant reference to the current simulator backend.
*/
sal::SimulatorController const& getSimulator() const { return sal::simulator; };
/**
* Add a experiment parameter set.
* The user campaign has to allocate the Parameter object,
* and deallocate it after result reception.
* A Parameter set includes space for results.
* @param exp A pointer to a ExperimentData set.
*/
void addParam(ExperimentData* exp) { m_jobserver.addParam(exp); };
/**
* A user campaign can request a single result (blocking) from the queue.
*
* @return Pointer to a parameter object with filled result data
* @see addParam.
*/
ExperimentData* getDone() { return m_jobserver.getDone(); };
/**
* Signal, that there will not come any further parameter sets.
*/
void noMoreParameters() { m_jobserver.setNoMoreExperiments(); };
/**
* Wait actively, until all experiments expired.
*/
// void waitForCompletion();
/**
* User campaign has finished.
*/
void done() { m_jobserver.done(); };
class CampaignManager {
private:
JobServer m_jobserver;
Campaign* m_currentCampaign;
public:
CampaignManager() { }
/**
* Executes a user campaign
*/
bool runCampaign(Campaign* c)
{
m_currentCampaign = c;
bool ret = c->run();
m_jobserver.done();
return ret;
}
/**
* Returns a const reference for acquiring constant simulator specific information.
* e.g., Registernames, to ease experiment data construction.
* The campaign description is not allowed to change the simulator
* state, as the actual simulation runs within another process (Minion)
* @return constant reference to the current simulator backend.
*/
SimulatorController const& getSimulator() const { return simulator; }
/**
* Add a experiment parameter set.
* The user campaign has to allocate the Parameter object,
* and deallocate it after result reception.
* A Parameter set includes space for results.
* @param exp A pointer to a ExperimentData set.
*/
void addParam(ExperimentData* exp) { m_jobserver.addParam(exp); }
/**
* A user campaign can request a single result (blocking) from the queue.
* @return Pointer to a parameter object with filled result data
* @see addParam()
*/
ExperimentData* getDone() { return m_jobserver.getDone(); }
/**
* Signal, that there will not come any further parameter sets.
*/
void noMoreParameters() { m_jobserver.setNoMoreExperiments(); }
/**
* Wait actively, until all experiments expired.
*/
// void waitForCompletion();
/**
* User campaign has finished.
*/
void done() { m_jobserver.done(); }
};
extern CampaignManager campaignmanager;
} //end-of-namespace
#endif
} // end-of-namespace: fail
#endif // __CAMPAIGN_MANAGER_HPP__

View File

@ -1,29 +1,26 @@
// Author: Adrian Böckenkamp
// Date: 05.10.2011
#include <iostream>
#include <cassert>
#include "CoroutineManager.hpp"
#include "../controller/ExperimentFlow.hpp"
namespace fi
{
namespace fail {
void CoroutineManager::m_invoke(void* pData)
{
//std::cerr << "CORO m_invoke " << co_current() << std::endl;
// TODO: Log-Level?
reinterpret_cast<ExperimentFlow*>(pData)->coroutine_entry();
//m_togglerstack.pop(); // FIXME need to pop our caller
//m_togglerstack.pop();
// FIXME: need to pop our caller
co_exit(); // deletes the associated coroutine memory as well
// we really shouldn't get here
std::cerr << "CoroutineManager::m_invoke() shitstorm unloading" << std::endl;
while (1) ;
// We really shouldn't get here:
assert(false && "FATAL ERROR: CoroutineManager::m_invoke() -- shitstorm unloading!");
while (1); // freeze.
}
CoroutineManager::~CoroutineManager()
{
}
CoroutineManager::~CoroutineManager() { }
void CoroutineManager::toggle(ExperimentFlow* flow)
{
@ -94,4 +91,4 @@ ExperimentFlow* CoroutineManager::getCurrent()
const ExperimentFlow* CoroutineManager::SIM_FLOW = NULL;
}
} // end-of-namespace: fail

View File

@ -1,17 +1,12 @@
#ifndef __COROUTINE_MANAGER_HPP__
#define __COROUTINE_MANAGER_HPP__
// Author: Adrian Böckenkamp
// Date: 05.10.2011
#include <map>
#include <stack>
#include <pcl.h> // the underlying "portable coroutine library"
namespace fi
{
namespace fail {
class ExperimentFlow;
@ -73,6 +68,6 @@ class CoroutineManager
ExperimentFlow* getCurrent();
};
} // end-of-namespace: fi
} // end-of-namespace: fail
#endif /* __COROUTINE_MANAGER_HPP__ */
#endif // __COROUTINE_MANAGER_HPP__

View File

@ -1,8 +1,7 @@
#include "Event.hpp"
#include "../SAL/SALInst.hpp"
namespace fi
{
namespace fail {
EventId BaseEvent::m_Counter = 0;
@ -42,7 +41,7 @@ bool TroubleEvent::addWatchNumber(unsigned troubleNumber)
return true;
}
bool MemAccessEvent::isMatching(sal::address_t addr, accessType_t accesstype) const
bool MemAccessEvent::isMatching(address_t addr, accessType_t accesstype) const
{
if(!(m_WatchType & accesstype))
return (false);
@ -52,20 +51,20 @@ bool MemAccessEvent::isMatching(sal::address_t addr, accessType_t accesstype) co
return (true);
}
bool BPEvent::aspaceIsMatching(sal::address_t aspace) const
bool BPEvent::aspaceIsMatching(address_t aspace) const
{
if (m_CR3 == ANY_ADDR || m_CR3 == aspace)
return true;
return false;
}
void BPRangeEvent::setWatchInstructionPointerRange(sal::address_t start, sal::address_t end)
void BPRangeEvent::setWatchInstructionPointerRange(address_t start, address_t end)
{
m_WatchStartAddr = start;
m_WatchEndAddr = end;
}
bool BPRangeEvent::isMatching(sal::address_t addr, sal::address_t aspace) const
bool BPRangeEvent::isMatching(address_t addr, address_t aspace) const
{
if (!aspaceIsMatching(aspace))
return false;
@ -75,7 +74,7 @@ bool BPRangeEvent::isMatching(sal::address_t addr, sal::address_t aspace) const
return true;
}
bool BPSingleEvent::isMatching(sal::address_t addr, sal::address_t aspace) const
bool BPSingleEvent::isMatching(address_t addr, address_t aspace) const
{
if (aspaceIsMatching(aspace)) {
if (m_WatchInstrPtr == ANY_ADDR || m_WatchInstrPtr == addr) {
@ -85,4 +84,4 @@ bool BPSingleEvent::isMatching(sal::address_t addr, sal::address_t aspace) const
return false;
}
} // end-of-namespace: fi
} // end-of-namespace: fail

View File

@ -6,19 +6,20 @@
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include "../SAL/SALConfig.hpp"
#include <iostream>
namespace fi
{
namespace fail {
class ExperimentFlow;
typedef unsigned long EventId; //!< type of event ids
//! invalid event id (used as a return indicator)
const EventId INVALID_EVENT = (EventId)-1;
//! address wildcard (e.g. for BPEvent)
const sal::address_t ANY_ADDR = static_cast<sal::address_t>(-1);
//! address wildcard (e.g. for BPEvent's)
const address_t ANY_ADDR = static_cast<address_t>(-1);
//! instruction wildcard
const unsigned ANY_INSTR = static_cast<unsigned>(-1);
//! trap wildcard
@ -93,9 +94,6 @@ class BaseEvent
*/
void setParent(ExperimentFlow* pFlow) { m_Parent = pFlow; }
};
// FIXME: Dynamische Casts zur Laufzeit evtl. zu uneffizient?
// (vgl. auf NULL evtl. akzeptabel?) Bessere Lösungen?
// ----------------------------------------------------------------------------
// Specialized events:
//
@ -107,8 +105,8 @@ class BaseEvent
class BPEvent : virtual public BaseEvent
{
private:
sal::address_t m_CR3;
sal::address_t m_TriggerInstrPtr;
address_t m_CR3;
address_t m_TriggerInstrPtr;
public:
/**
* Creates a new breakpoint event. The range information is specific to
@ -119,37 +117,37 @@ class BPEvent : virtual public BaseEvent
* ANY_ADDR can be used as a placeholder to allow debugging
* in a random address space.
*/
BPEvent(sal::address_t address_space = ANY_ADDR)
BPEvent(address_t address_space = ANY_ADDR)
: m_CR3(address_space), m_TriggerInstrPtr(ANY_ADDR)
{}
/**
* Returns the address space register of this event.
*/
sal::address_t getCR3() const
address_t getCR3() const
{ return m_CR3; }
/**
* Sets the address space register for this event.
*/
void setCR3(sal::address_t iptr)
void setCR3(address_t iptr)
{ m_CR3 = iptr; }
/**
* Checks whether a given address space is matching.
*/
bool aspaceIsMatching(sal::address_t address_space = ANY_ADDR) const;
bool aspaceIsMatching(address_t address_space = ANY_ADDR) const;
/**
* Checks whether a given address is matching.
*/
virtual bool isMatching(sal::address_t addr = 0, sal::address_t address_space = ANY_ADDR) const = 0;
virtual bool isMatching(address_t addr = 0, address_t address_space = ANY_ADDR) const = 0;
/**
* Returns the instruction pointer that triggered this event.
*/
sal::address_t getTriggerInstructionPointer() const
address_t getTriggerInstructionPointer() const
{ return m_TriggerInstrPtr; }
/**
* Sets the instruction pointer that triggered this event. Should not
* be used by experiment code.
*/
void setTriggerInstructionPointer(sal::address_t iptr)
void setTriggerInstructionPointer(address_t iptr)
{ m_TriggerInstrPtr = iptr; }
};
@ -160,7 +158,7 @@ class BPEvent : virtual public BaseEvent
class BPSingleEvent : virtual public BPEvent
{
private:
sal::address_t m_WatchInstrPtr;
address_t m_WatchInstrPtr;
public:
/**
* Creates a new breakpoint event.
@ -174,22 +172,22 @@ class BPSingleEvent : virtual public BPEvent
* Here, too, ANY_ADDR is a placeholder to allow debugging
* in a random address space.
*/
BPSingleEvent(sal::address_t ip = 0, sal::address_t address_space = ANY_ADDR)
BPSingleEvent(address_t ip = 0, address_t address_space = ANY_ADDR)
: BPEvent(address_space), m_WatchInstrPtr(ip) { }
/**
* Returns the instruction pointer this event waits for.
*/
sal::address_t getWatchInstructionPointer() const
address_t getWatchInstructionPointer() const
{ return m_WatchInstrPtr; }
/**
* Sets the instruction pointer this event waits for.
*/
void setWatchInstructionPointer(sal::address_t iptr)
void setWatchInstructionPointer(address_t iptr)
{ m_WatchInstrPtr = iptr; }
/**
* Checks whether a given address is matching.
*/
bool isMatching(sal::address_t addr, sal::address_t address_space) const;
bool isMatching(address_t addr, address_t address_space) const;
};
/**
@ -199,8 +197,8 @@ class BPSingleEvent : virtual public BPEvent
class BPRangeEvent : virtual public BPEvent
{
private:
sal::address_t m_WatchStartAddr;
sal::address_t m_WatchEndAddr;
address_t m_WatchStartAddr;
address_t m_WatchEndAddr;
public:
/**
* Creates a new breakpoint-range event. The range's ends are both
@ -208,24 +206,24 @@ class BPRangeEvent : virtual public BPEvent
* ANY_ADDR denotes the lower respectively the upper end of the address
* space.
*/
BPRangeEvent(sal::address_t start = 0, sal::address_t end = 0, sal::address_t address_space = ANY_ADDR)
BPRangeEvent(address_t start = 0, address_t end = 0, address_t address_space = ANY_ADDR)
: BPEvent(address_space), m_WatchStartAddr(start), m_WatchEndAddr(end)
{ }
/**
* Returns the instruction pointer watch range of this event.
*/
std::pair<sal::address_t, sal::address_t> getWatchInstructionPointerRange() const
std::pair<address_t, address_t> getWatchInstructionPointerRange() const
{ return std::make_pair(m_WatchStartAddr, m_WatchEndAddr); }
/**
* Sets the instruction pointer watch range. Both ends of the range
* may be ANY_ADDR (cf. constructor).
*/
void setWatchInstructionPointerRange(sal::address_t start,
sal::address_t end);
void setWatchInstructionPointerRange(address_t start,
address_t end);
/**
* Checks whether a given address is within the range.
*/
bool isMatching(sal::address_t addr, sal::address_t address_space) const;
bool isMatching(address_t addr, address_t address_space) const;
};
/**
@ -246,18 +244,18 @@ class MemAccessEvent : virtual public BaseEvent
};
private:
//! Specific guest system address to watch, or ANY_ADDR.
sal::address_t m_WatchAddr;
address_t m_WatchAddr;
/**
* Memory access type we want to watch
* (MEM_READ || MEM_WRITE || MEM_READWRITE).
*/
accessType_t m_WatchType;
//! Specific guest system address that actually triggered the event.
sal::address_t m_TriggerAddr;
address_t m_TriggerAddr;
//! Width of the memory access (# bytes).
size_t m_TriggerWidth;
//! Address of the instruction that caused the memory access.
sal::address_t m_TriggerIP;
address_t m_TriggerIP;
//! Memory access type at m_TriggerAddr.
accessType_t m_AccessType;
public:
@ -265,7 +263,7 @@ class MemAccessEvent : virtual public BaseEvent
: m_WatchAddr(ANY_ADDR), m_WatchType(watchtype),
m_TriggerAddr(ANY_ADDR), m_TriggerIP(ANY_ADDR),
m_AccessType(MEM_UNKNOWN) { }
MemAccessEvent(sal::address_t addr,
MemAccessEvent(address_t addr,
accessType_t watchtype = MEM_READWRITE)
: m_WatchAddr(addr), m_WatchType(watchtype),
m_TriggerAddr(ANY_ADDR), m_TriggerIP(ANY_ADDR),
@ -273,25 +271,25 @@ class MemAccessEvent : virtual public BaseEvent
/**
* Returns the memory address to be observed.
*/
sal::address_t getWatchAddress() const { return m_WatchAddr; }
address_t getWatchAddress() const { return m_WatchAddr; }
/**
* Sets the memory address to be observed. (Wildcard: ANY_ADDR)
*/
void setWatchAddress(sal::address_t addr) { m_WatchAddr = addr; }
void setWatchAddress(address_t addr) { m_WatchAddr = addr; }
/**
* Checks whether a given address is matching.
*/
bool isMatching(sal::address_t addr, accessType_t accesstype) const;
bool isMatching(address_t addr, accessType_t accesstype) const;
/**
* Returns the specific memory address that actually triggered the
* event.
*/
sal::address_t getTriggerAddress() const { return (m_TriggerAddr); }
address_t getTriggerAddress() const { return (m_TriggerAddr); }
/**
* Sets the specific memory address that actually triggered the event.
* Should not be used by experiment code.
*/
void setTriggerAddress(sal::address_t addr) { m_TriggerAddr = addr; }
void setTriggerAddress(address_t addr) { m_TriggerAddr = addr; }
/**
* Returns the specific memory address that actually triggered the
* event.
@ -306,13 +304,13 @@ class MemAccessEvent : virtual public BaseEvent
* Returns the address of the instruction causing this memory
* access.
*/
sal::address_t getTriggerInstructionPointer() const
address_t getTriggerInstructionPointer() const
{ return (m_TriggerIP); }
/**
* Sets the address of the instruction causing this memory
* access. Should not be used by experiment code.
*/
void setTriggerInstructionPointer(sal::address_t addr)
void setTriggerInstructionPointer(address_t addr)
{ m_TriggerIP = addr; }
/**
* Returns type (MEM_READ || MEM_WRITE) of the memory access that
@ -330,6 +328,7 @@ class MemAccessEvent : virtual public BaseEvent
*/
accessType_t getWatchAccessType() const { return (m_WatchType); }
};
/**
* \class MemReadEvent
* Observes memory read accesses.
@ -339,7 +338,7 @@ class MemReadEvent : virtual public MemAccessEvent
public:
MemReadEvent()
: MemAccessEvent(MEM_READ) { }
MemReadEvent(sal::address_t addr)
MemReadEvent(address_t addr)
: MemAccessEvent(addr, MEM_READ) { }
};
@ -352,7 +351,7 @@ class MemWriteEvent : virtual public MemAccessEvent
public:
MemWriteEvent()
: MemAccessEvent(MEM_READ) { }
MemWriteEvent(sal::address_t addr)
MemWriteEvent(address_t addr)
: MemAccessEvent(addr, MEM_WRITE) { }
};
@ -582,7 +581,7 @@ class TimerEvent : public BaseEvent
{
private:
unsigned m_Timeout; //!< timeout interval in milliseconds
sal::timer_id_t m_Id; //!< internal timer id (sim-specific)
timer_id_t m_Id; //!< internal timer id (sim-specific)
bool m_Once; //!< true, if the timer should be triggered only once
public:
/**
@ -600,12 +599,12 @@ class TimerEvent : public BaseEvent
* Retrieves the internal timer id. Maybe useful for debug output.
* @return the timer id
*/
sal::timer_id_t getId() const { return m_Id; }
timer_id_t getId() const { return m_Id; }
/**
* Sets the internal timer id. This should not be used by the experiment.
* @param id the new timer id, given by the underlying simulator-backend
*/
void setId(sal::timer_id_t id) { m_Id = id; }
void setId(timer_id_t id) { m_Id = id; }
/**
* Retrieves the timer's timeout value.
* @return the timout in milliseconds
@ -618,6 +617,6 @@ class TimerEvent : public BaseEvent
bool getOnceFlag() const { return m_Once; }
};
} // end-of-namespace: fi
} // end-of-namespace: fail
#endif /* __EVENT_HPP__ */
#endif // __EVENT_HPP__

View File

@ -3,9 +3,8 @@
#include "EventList.hpp"
#include "../SAL/SALInst.hpp"
namespace fi
{
namespace fail {
EventId EventList::add(BaseEvent* ev, ExperimentFlow* pExp)
{
assert(ev != NULL && "FATAL ERROR: Event (of base type BaseEvent*) cannot be NULL!");
@ -28,9 +27,9 @@ void EventList::remove(BaseEvent* ev)
// * copy m_FireList to m_DeleteList
if (ev == 0) {
for (bufferlist_t::iterator it = m_BufferList.begin(); it != m_BufferList.end(); it++)
sal::simulator.onEventDeletion(*it);
simulator.onEventDeletion(*it);
for (firelist_t::iterator it = m_FireList.begin(); it != m_FireList.end(); it++)
sal::simulator.onEventDeletion(*it);
simulator.onEventDeletion(*it);
m_Bp_cache.clear();
m_BufferList.clear();
// all remaining active events must not fire anymore
@ -40,7 +39,7 @@ void EventList::remove(BaseEvent* ev)
// * find/remove ev in m_BufferList
// * if ev in m_FireList, copy to m_DeleteList
} else {
sal::simulator.onEventDeletion(ev);
simulator.onEventDeletion(ev);
BPEvent *bp_ev;
if((bp_ev = dynamic_cast<BPEvent*>(ev)) != NULL)
@ -67,7 +66,7 @@ EventList::iterator EventList::m_remove(iterator it, bool skip_deletelist)
// from the buffer list to the fire-list. Therefor we only need to call the simulator's
// event handler (m_onEventDeletion), if m_remove is called with the primary intention
// to *delete* (not "move") an event.
sal::simulator.onEventDeletion(*it);
simulator.onEventDeletion(*it);
m_DeleteList.push_back(*it);
}
@ -82,7 +81,7 @@ void EventList::remove(ExperimentFlow* flow)
// WARNING: (*it) (= all elements in the lists) can be an invalid ptr because
// clearEvents will be called automatically when the allocating experiment (i.e.
// run()) has already ended. Accordingly, we cannot call
// sal::simulator.onEventDeletion(*it)
// simulator.onEventDeletion(*it)
// because a dynamic-cast of *it would cause a SEGFAULT. Therefor we require the
// experiment flow to remove all residual events by calling clearEvents() (with-
// in run()). As a consequence, we are now allowed to call the event-handler here.
@ -92,14 +91,14 @@ void EventList::remove(ExperimentFlow* flow)
if (flow == 0) {
for (bufferlist_t::iterator it = m_BufferList.begin();
it != m_BufferList.end(); it++)
sal::simulator.onEventDeletion(*it); // invoke event handler
simulator.onEventDeletion(*it); // invoke event handler
m_Bp_cache.clear();
m_BufferList.clear();
} else { // remove all events corresponding to a specific experiment ("flow"):
for (bufferlist_t::iterator it = m_BufferList.begin();
it != m_BufferList.end(); ) {
if ((*it)->getParent() == flow) {
sal::simulator.onEventDeletion(*it);
simulator.onEventDeletion(*it);
it = m_BufferList.erase(it);
} else {
++it;
@ -116,7 +115,7 @@ void EventList::remove(ExperimentFlow* flow)
// ... need to be pushed into m_DeleteList, as we're currently
// iterating over m_FireList in fireActiveEvents() and cannot modify it
if (flow == 0 || (*it)->getParent() == flow) {
sal::simulator.onEventDeletion(*it);
simulator.onEventDeletion(*it);
m_DeleteList.push_back(*it);
}
}
@ -160,14 +159,14 @@ void EventList::fireActiveEvents()
for (firelist_t::iterator it = m_FireList.begin();
it != m_FireList.end(); it++) {
if (std::find(m_DeleteList.begin(), m_DeleteList.end(), *it)
== m_DeleteList.end()) { // not found in delete-list?
== m_DeleteList.end()) { // not found in delete-list?
m_pFired = *it;
// Inform (call) the simulator's (internal) event handler that we are about
// to trigger an event (*before* we actually toggle the experiment flow):
sal::simulator.onEventTrigger(m_pFired);
simulator.onEventTrigger(m_pFired);
ExperimentFlow* pFlow = m_pFired->getParent();
assert(pFlow && "FATAL ERROR: The event has no parent experiment (owner)!");
sal::simulator.m_Flows.toggle(pFlow);
simulator.m_Flows.toggle(pFlow);
}
}
m_FireList.clear();
@ -177,11 +176,12 @@ void EventList::fireActiveEvents()
size_t EventList::getContextCount() const
{
set<ExperimentFlow*> uniqueFlows; // count unique ExperimentFlow-ptr
std::set<ExperimentFlow*> uniqueFlows; // count unique ExperimentFlow-ptr
for(bufferlist_t::const_iterator it = m_BufferList.begin();
it != m_BufferList.end(); it++)
uniqueFlows.insert((*it)->getParent());
return (uniqueFlows.size());
return uniqueFlows.size();
}
} // end-of-namespace: fi
} // end-of-namespace: fail

View File

@ -9,8 +9,7 @@
#include "Event.hpp"
#include "BufferCache.hpp"
namespace fi
{
namespace fail {
class ExperimentFlow;
@ -49,10 +48,10 @@ typedef std::vector<BaseEvent*> deletelist_t;
class EventList
{
private:
// TODO: List separation of "critical types"? Hashing/sorted lists? (-> performance!)
bufferlist_t m_BufferList; //!< the storage for events added by exp.
firelist_t m_FireList; //!< the active events (used temporarily)
deletelist_t m_DeleteList; //!< the deleted events (used temporarily)
// TODO: Hashing?
BaseEvent* m_pFired; //!< the recently fired Event-object
BufferCache<BPEvent*> m_Bp_cache;
public:
@ -189,6 +188,6 @@ class EventList
inline BufferCache<BPEvent*> *getBPBuffer() { return &m_Bp_cache; }
};
}; // end-of-namespace: fi
} // end-of-namespace: fail
#endif /* __EVENT_LIST_HPP__ */
#endif // __EVENT_LIST_HPP__

View File

@ -1,56 +1,51 @@
/**
* \brief ExperimentData interface
*
* This is the base class for all user-defined data types for
* \brief This is the base class for all user-defined data types for
* expirement parameter and results.
*
* \author Martin Hoffmann, Richard Hellwig
*
*/
#ifndef __EXPERIMENT_DATA_H__
#define __EXPERIMENT_DATA_H__
#ifndef __EXPERIMENT_DATA_HPP__
#define __EXPERIMENT_DATA_HPP__
#include <string>
#include <google/protobuf/message.h>
using namespace std;
namespace fi{
namespace fail {
/**
* \class ExperimentData
* Container for experiment data with wrapper methods for serialization and deserialization.
*/
class ExperimentData
{
protected:
google::protobuf::Message* msg;
uint32_t m_workloadID;
public:
ExperimentData() : msg(0), m_workloadID(0) {};
ExperimentData(google::protobuf::Message* m) : msg(m) , m_workloadID(0) {};
class ExperimentData
{
protected:
google::protobuf::Message* msg;
uint32_t m_workloadID;
public:
ExperimentData() : msg(0), m_workloadID(0) {};
ExperimentData(google::protobuf::Message* m) : msg(m) , m_workloadID(0) {};
google::protobuf::Message& getMessage() { return *msg; };
uint32_t getWorkloadID() const { return m_workloadID;};
void setWorkloadID(uint32_t id) { m_workloadID = id; };
/**
* Serializes the ExperimentData.
* @param ped output the target-stream.
* @return \c true if the serialization was successful, \c false otherwise
*/
bool serialize(ostream * output) const { return msg->SerializeToOstream(output); }
/**
* Unserializes the ExperimentData.
* @param ped input the stream which is read from
* @return \c true if the unserialization was successful, \c false otherwise
*/
bool unserialize(istream * input) { return msg->ParseFromIstream(input); }
string DebugString() const { return msg->DebugString(); };
};
google::protobuf::Message& getMessage() { return *msg; };
uint32_t getWorkloadID() const { return m_workloadID;};
void setWorkloadID(uint32_t id) { m_workloadID = id; };
/**
* Serializes the ExperimentData.
* @param ped output the target-stream.
* @return \c true if the serialization was successful, \c false otherwise
*/
bool serialize(std::ostream* output) const { return msg->SerializeToOstream(output); }
/**
* Unserializes the ExperimentData.
* @param ped input the stream which is read from
* @return \c true if the unserialization was successful, \c false otherwise
*/
bool unserialize(std::istream* input) { return msg->ParseFromIstream(input); }
/**
* Returns a debug string.
* @return the debug string
*/
std::string debugString() const { return msg->DebugString(); };
};
#endif //__EXPERIMENT_DATA_H__
} // end-of-namespace: fail
#endif //__EXPERIMENT_DATA_HPP__

View File

@ -2,6 +2,8 @@
#include <assert.h>
// FIXME: This is deprecated stuff. Remove it.
namespace fi
{

View File

@ -6,6 +6,8 @@
*
*/
// FIXME: This is deprecated stuff. Remove it.
#ifndef __EXPERIMENT_DATA_QUEUE_H__
#define __EXPERIMENT_DATA_QUEUE_H__

View File

@ -3,8 +3,7 @@
#include "../SAL/SALInst.hpp"
namespace fi
{
namespace fail {
/**
* \class ExperimentFlow
@ -20,7 +19,6 @@ class ExperimentFlow
* @return \c true if the experiment was successful, \c false otherwise
*/
virtual bool run() = 0;
/**
* The entry point for this experiment's coroutine.
* Should do some cleanup afterwards.
@ -28,13 +26,13 @@ class ExperimentFlow
void coroutine_entry()
{
run();
sal::simulator.clearEvents(this); // remove residual events
simulator.clearEvents(this); // remove residual events
// FIXME: Consider removing this call (see EventList.cc, void remove(ExperimentFlow* flow))
// a) with the advantage that we will potentially prevent serious segfaults but
// b) with the drawback that we cannot enforce any cleanups.
}
};
}
} // end-of-namespace: fail
#endif /* __EXPERIMENT_FLOW_HPP__ */
#endif // __EXPERIMENT_FLOW_HPP__

View File

@ -1,17 +1,17 @@
/**
* \brief The representation of a minion.
*
* \author Richard Hellwig
*
*/
#ifndef __MINION_HPP__
#define __MINION_HPP__
#include <string>
#include "controller/ExperimentData.hpp"
namespace fi
{
namespace fail {
/**
* \class Minion
*
@ -20,26 +20,32 @@ namespace fi
class Minion
{
private:
string hostname;
std::string hostname;
bool isWorking;
ExperimentData* currentExperimentData;
int sockfd;
public:
Minion() : isWorking(false), currentExperimentData(0), sockfd(-1) { }
/**
* Sets the socket descriptor.
* @param sock the new socket descriptor (used internal)
*/
void setSocketDescriptor(int sock) { sockfd = sock; }
/**
* Retrives the socket descriptor.
* @return the socket descriptor
*/
int getSocketDescriptor() const { return (sockfd); }
/**
* Returns the hostname of the minion.
* @return the hostname
*/
string getHostname() { return (hostname); }
const std::string& getHostname() { return (hostname); }
/**
* Sets the hostname of the minion.
* @param host the hostname
*/
void setHostname(string host) { hostname = host; }
void setHostname(const std::string& host) { hostname = host; }
/**
* Returns the current ExperimentData which the minion is working with.
* @return a pointer of the current ExperimentData
@ -62,6 +68,6 @@ class Minion
void setBusy(bool state) { isWorking = state; }
};
};
} // end-of-namespace: fail
#endif /* __MINION_HPP__ */
#endif // __MINION_HPP__

View File

@ -2,6 +2,8 @@
// Author: Adrian Böckenkamp
// Date: 15.06.2011
// FIXME: This is deprecated stuff. Delete it.
#include "Signal.hpp"
namespace fi

View File

@ -1,8 +1,7 @@
#ifndef __SIGNAL_HPP__
#define __SIGNAL_HPP__
// Author: Adrian Böckenkamp
// Date: 15.06.2011
// FIXME: This is deprecated stuff. Delete it.
#include <cassert>
#include <memory>

View File

@ -1,5 +1,7 @@
#include "SynchronizedExperimentDataQueue.hpp"
// FIXME: This file is not used. Delete it either.
namespace fi {
void SynchronizedExperimentDataQueue::addData(ExperimentData* exp){
@ -20,4 +22,4 @@ ExperimentData* SynchronizedExperimentDataQueue::getData(){
}
};
};

View File

@ -6,6 +6,8 @@
*
*/
// FIXME: This file is not used. Delete it.
#ifndef __SYNC_EXPERIMENT_DATA_QUEUE_H__
#define __SYNC_EXPERIMENT_DATA_QUEUE_H__