Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,427 changes: 2,427 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/cbserver/cbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main()
ttrace.attachToTask(&t2);
ttrace.attachToTask(&t3);

CBServer serv(4, 15,15,'hard', "server1", "FIFOSched");//"RRSched(2);");
CBServer serv(4, 15,15,CBServer::HARD, "server1", "FIFOSched");//"RRSched(2);");
serv.addTask(t11);
serv.addTask(t12);
kern.addTask(serv, "");
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ elseif(WIN32)
endif()

# Create a library called "rtlib" which includes the source files.
add_library(rtlib ${LIB_TYPE} capacitytimer.cpp cbserver.cpp cpu.cpp
add_library(rtlib ${LIB_TYPE} capacitytimer.cpp hsrpmanager.cpp srpresmanager.cpp broeserver.cpp cbserver.cpp cpu.cpp
edfsched.cpp exeinstr.cpp fcfsresmanager.cpp feedback.cpp feedbacktest.cpp
fifosched.cpp fpsched.cpp grubserver.cpp interrupt.cpp jtrace.cpp
kernel.cpp kernevt.cpp load.cpp mrtkernel.cpp piresman.cpp pollingserver.cpp
Expand Down
8 changes: 7 additions & 1 deletion src/abskernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define __ABSKERNEL_HPP__

#include <abstask.hpp>
#include <vector>

namespace RTSim {

Expand Down Expand Up @@ -85,7 +86,12 @@ namespace RTSim {
virtual double setSpeed(double newLoad) = 0;

/** ??? */
virtual bool isContextSwitching() const = 0;
virtual bool isContextSwitching() const = 0;

/** Modica Celia - 14/10/2010
Return the task list
*/
virtual std::vector<AbsRTTask*> getTasks() const = 0;

};

Expand Down
5 changes: 5 additions & 0 deletions src/abstask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ namespace RTSim {
/// returns the wcet for this task, if available! otherwise returns 0.
virtual Tick getMaxExecutionTime() const { return 0; }

/**
*
*/


};

/**
Expand Down
112 changes: 112 additions & 0 deletions src/broeserver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include "broeserver.hpp"

namespace RTSim
{
using namespace MetaSim;

BROEServer::BROEServer(Tick q, Tick p, Tick d, const string &name, RHTmap_t *R, const string &sched):
CBServer(q,p,d,HARD,name,sched),
RHTs(R),
_recwaitEvt(this, &BROEServer::rechargeAfterWaiting, Event::_DEFAULT_PRIORITY - 1),
task_wait_res(nullptr),
res_for_wait(""),
n_res_manager(0)
{
RHTmap_t::iterator I = RHTs->begin();
while (I != RHTs->end())
{
if (I->second > q)
throw BROEExc(I->first+" has a rht greater then Server budget","BROEServer::BROEServer()");
I++;
}
}

bool BROEServer::requestResource(AbsRTTask *t, const string &r, int n)
throw(BROEExc)
{
DBGENTER(_KERNEL_DBG_LEV);

SRPManager *m = dynamic_cast<SRPManager*>(localResmanager);
HSRPManager *gm = dynamic_cast<HSRPManager*>(globResManager);
bool ret = false;
if (!m)
throw BROEExc("Broe needs local SRP manager!","BROEServer::requestResource()");
if (!gm)
throw BROEExc("Broe needs global HSRP manager!","BROEServer::requestResource()");


if (gm->find(r))
{
RHTmap_t::iterator I;
I = RHTs->find(taskname(t)+"_"+r);
if (I == RHTs->end())
throw BROEExc("No RHT for "+taskname(t)+"_"+r,"BROEServer::requestResource()");


Tick curr_RHT = I->second;
Tick curr_budget = get_remaining_budget();

///Disable the local preemption of the Server
/// rising the local Ceiling level to the max
localResmanager->request(t,r,n);

/// Budget enough
if ( curr_budget >= curr_RHT)
{
ret = globResManager->request(t,this,r,n);
if (!ret)
kernel->dispatch();
return ret;
}

///calculating time to recharg
double alpha = double(Q) / double(P);
Tick tr = getDeadline() - Tick::floor((double(curr_budget) / alpha) + 0.000000001);

///check if waiting before recharge
if (SIMUL.getTime() < tr)
{
status = WAITING;
_bandExEvt.drop();
vtime.stop();
_recwaitEvt.post(tr);
task_wait_res = t;
res_for_wait = r;
n_res_manager = n;
ret = false;
}else
{
_bandExEvt.drop();
vtime.stop();
cap = Q;
last_time = SIMUL.getTime();
d=tr+P;
setAbsDead(d);
vtime.start((double)P/double(Q));
_bandExEvt.post(last_time + cap);
ret = globResManager->request(t,this,r,n);
}
} else
ret = localResmanager->request(t,r,n);
if (!ret)
dispatch();
return ret;
}

void BROEServer::rechargeAfterWaiting(Event *e)
{
assert(status == WAITING);
if (task_wait_res == nullptr)
throw BROEExc("No task waiting for resource","BROEServer::rechargeAfterWaiting(Event *e)");
cap = Q;
d=SIMUL.getTime()+P;
setAbsDead(d);
status = EXECUTING;
last_time = SIMUL.getTime();
vtime.start((double)P/double(Q));
_bandExEvt.post(SIMUL.getTime() + cap);
globResManager->request(task_wait_res,this,res_for_wait,n_res_manager);
dispatch();
kernel->dispatch();
}
}
101 changes: 101 additions & 0 deletions src/broeserver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#ifndef __BROESERVER_H__
#define __BROESERVER_H__

#include <cbserver.hpp>
#include <cassert>

namespace RTSim
{
using namespace MetaSim;

using namespace std;

/**
* Class that exted Base Exeption
* for launch BROEExc exeption
*/
class BROEExc : public ServerExc
{
public:
BROEExc(const string& m, const string& cl) :
ServerExc(m,cl,"BROEServer") {};
};

typedef map<const string, Tick> RHTmap_t;

/**
\ingroup resman

This class implements the BROE Server.
Based on an Hard CBS Server with local SRP manager and
global H-SRP manager.

@authors Modica Paolo, Marco Celia
@version 1.0
*/
class BROEServer : public CBServer
{

/// List of all Worst Case Resource Holding Time of a resource for each tasks
RHTmap_t *RHTs;

///Param to save the data for block the resource at the recharging time (requesting task)
AbsRTTask *task_wait_res;
///Param to save the data for block the resource at the recharging time (requested resource's name)
string res_for_wait;
///Param to save the data for block the resource at the recharging time (requested resource's units)
int n_res_manager;

public:
/**
The Constractor
@param q Budget
@param p Period
@param d Relative Deadline
@param name Name of the Server
@param R Table of all Tasks' resources holding times
@param sched Local scheduler policy

@warning Broe server supports only EDF and RM scheduler
@todo Implement support for other scheduler policy
*/
BROEServer(Tick q, Tick p, Tick d, const string &name, RHTmap_t *R,
const string &sched = "EDFSched");

protected:

/// Recharging after wait event
GEvent<BROEServer> _recwaitEvt;

/**
Recharging after wait event (_recwaitEvt) handler
@param e Event
*/
void rechargeAfterWaiting(Event *e);
public:
/**
* Forwards the request of resource r from task t to
* the global or local resource manager.
* If resource managers were
* not been set, a BROEExc exception is raised.
*
* @param t requesting task
* @param r requested resource's name
* @param n requested resource's units
*
* @return True if the local ora global resource has been locked
*
* @todo implements the support for n > 1
*/
virtual bool requestResource(AbsRTTask *t, const string &r, int n=1)
throw(BROEExc);

};




}


#endif
8 changes: 4 additions & 4 deletions src/capacitytimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ namespace RTSim {
{
assert(status == RUNNING);
//value += Tick::ceil(double(SIMUL.getTime() - last_time) * der);
value += double(SIMUL.getTime() - last_time) * der;
value += double(SIMUL.getTime() - last_time) * der;
status = STOPPED;
return value;
}

Tick CapacityTimer::get_intercept(const Tick &v) const
{
assert(status == RUNNING && der != 0);
return Tick::floor((double(v) - get_value()) / der);
assert(status == RUNNING && der != 0);
return Tick::floor((double(v) - get_value()) / der);
}

double CapacityTimer::get_value() const
{
if (status == RUNNING)
//return value + Tick::ceil(double(SIMUL.getTime() - last_time) * der);
return value + double(SIMUL.getTime() - last_time) * der;
return value + double(SIMUL.getTime() - last_time) * der;
else return value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/capacitytimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace RTSim {
private:
Tick last_time;
//Tick value;
double value;
double value;
status_t status;
double der;
};
Expand Down
Loading