- Improved resource policy power
- added tests for gap management - added test for resource policy git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@971 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
4f3e8f61df
commit
c797bf97ae
|
@ -56,7 +56,7 @@ ConcreteSimulation::get_mode() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConcreteSimulation::jump_to(History::position p)
|
ConcreteSimulation::jump_to(History::position p) throw(UserInterruptException, NullPolicyException, MalformedPolicyException)
|
||||||
{
|
{
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace sgpem
|
||||||
|
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
void jump_to(History::position p);
|
void jump_to(History::position p) throw(UserInterruptException, NullPolicyException, MalformedPolicyException);
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "policy_parameters.hh"
|
#include "policy_parameters.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
#include "environment.hh"
|
||||||
|
#include "sub_request.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
|
@ -56,7 +58,7 @@ namespace sgpem
|
||||||
Because it's a pure virtual method, must be re-implemented
|
Because it's a pure virtual method, must be re-implemented
|
||||||
in concrete derived classes.
|
in concrete derived classes.
|
||||||
*/
|
*/
|
||||||
virtual void enforce() throw(UserInterruptException) = 0;
|
virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets a string description of the policy.
|
Gets a string description of the policy.
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "resource_policy_lifo.hh"
|
#include "resource_policy_lifo.hh"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
|
@ -39,10 +41,24 @@ ResourcePolicyLiFo::configure()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ResourcePolicyLiFo::enforce()
|
ResourcePolicyLiFo::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr)
|
||||||
throw(UserInterruptException)
|
throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
|
typedef Environment::SubRequestQueue SubRequestQueue;
|
||||||
printf("\nResourcePolicy 'LiFo' has been called.");
|
printf("\nResourcePolicy 'LiFo' has been called.");
|
||||||
|
|
||||||
|
// the last inserted request goes on the first free place.
|
||||||
|
SubRequestQueue old_queue(queue);
|
||||||
|
queue.clear();
|
||||||
|
|
||||||
|
typedef SubRequestQueue::iterator It;
|
||||||
|
for (It i = old_queue.begin(); i != old_queue.end(); i++)
|
||||||
|
{
|
||||||
|
// just rebuilds the queue by now.
|
||||||
|
queue.push_back(*i);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nResourcePolicy 'LiFo' has terminated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "glibmm/ustring.h"
|
#include "glibmm/ustring.h"
|
||||||
|
|
||||||
#include "resource_policy.hh"
|
#include "resource_policy.hh"
|
||||||
|
|
||||||
#include "policy_parameters.hh"
|
#include "policy_parameters.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ namespace sgpem
|
||||||
Because it's a pure virtual method, must be re-implemented
|
Because it's a pure virtual method, must be re-implemented
|
||||||
in concrete derived classes.
|
in concrete derived classes.
|
||||||
*/
|
*/
|
||||||
virtual void enforce() throw(UserInterruptException);
|
virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets a string description of the policy.
|
Gets a string description of the policy.
|
||||||
|
|
|
@ -176,7 +176,7 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
|
||||||
/// TODO: right here, right now we should call the resource policy to
|
/// TODO: right here, right now we should call the resource policy to
|
||||||
/// update the queue. Updates the state of the subrequest depending
|
/// update the queue. Updates the state of the subrequest depending
|
||||||
/// on the position in the queue, as explained before.
|
/// on the position in the queue, as explained before.
|
||||||
resource_policy.enforce();
|
//resource_policy.enforce(environment, queue, cur_subr);
|
||||||
|
|
||||||
// Get the number of places for the corresponding resource
|
// Get the number of places for the corresponding resource
|
||||||
Resource& resource = *environment.get_resources().find(rkey)->second;
|
Resource& resource = *environment.get_resources().find(rkey)->second;
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace sgpem
|
||||||
|
|
||||||
Pauses the simulation and jumps to the specified instant
|
Pauses the simulation and jumps to the specified instant
|
||||||
*/
|
*/
|
||||||
virtual void jump_to(History::position p) = 0;
|
virtual void jump_to(History::position p) throw(UserInterruptException, NullPolicyException, MalformedPolicyException) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
set cpu-policy 2
|
||||||
|
|
||||||
|
add resource
|
||||||
|
forchetta
|
||||||
|
1
|
||||||
|
|
||||||
|
add process
|
||||||
|
Pitagorici
|
||||||
|
0
|
||||||
|
0
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Pitagora
|
||||||
|
5
|
||||||
|
0
|
||||||
|
0
|
||||||
|
add request 1 1
|
||||||
|
0
|
||||||
|
add subrequest 1 1 1
|
||||||
|
0
|
||||||
|
5
|
||||||
|
|
||||||
|
|
||||||
|
add process
|
||||||
|
Scuola di Mileto
|
||||||
|
2
|
||||||
|
1
|
||||||
|
|
||||||
|
add thread 2
|
||||||
|
Anassimene
|
||||||
|
4
|
||||||
|
1
|
||||||
|
0
|
||||||
|
|
||||||
|
|
||||||
|
add thread 2
|
||||||
|
Anassimandro
|
||||||
|
2
|
||||||
|
0
|
||||||
|
0
|
||||||
|
add request 2 2
|
||||||
|
0
|
||||||
|
add subrequest 2 2 1
|
||||||
|
0
|
||||||
|
1
|
||||||
|
add subrequest 2 2 1
|
||||||
|
0
|
||||||
|
2
|
||||||
|
|
||||||
|
|
||||||
|
run
|
|
@ -0,0 +1,30 @@
|
||||||
|
set cpu-policy 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add process
|
||||||
|
Rivoluzione
|
||||||
|
0
|
||||||
|
1
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Copernico
|
||||||
|
3
|
||||||
|
0
|
||||||
|
0
|
||||||
|
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Bruno
|
||||||
|
2
|
||||||
|
3
|
||||||
|
0
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Galilei
|
||||||
|
3
|
||||||
|
6
|
||||||
|
0
|
||||||
|
|
||||||
|
run
|
|
@ -0,0 +1,64 @@
|
||||||
|
set cpu-policy 2
|
||||||
|
|
||||||
|
configure-cpu-policy
|
||||||
|
0
|
||||||
|
2
|
||||||
|
|
||||||
|
add resource
|
||||||
|
Telefono
|
||||||
|
1
|
||||||
|
|
||||||
|
add resource
|
||||||
|
Fax
|
||||||
|
1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add process
|
||||||
|
Ufficio Sinistri
|
||||||
|
0
|
||||||
|
5
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Fantozzi
|
||||||
|
7
|
||||||
|
0
|
||||||
|
5
|
||||||
|
add request 1 1
|
||||||
|
0
|
||||||
|
add subrequest 1 1 1
|
||||||
|
0
|
||||||
|
7
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Filini
|
||||||
|
3
|
||||||
|
2
|
||||||
|
4
|
||||||
|
add request 1 2
|
||||||
|
0
|
||||||
|
add subrequest 1 2 1
|
||||||
|
0
|
||||||
|
3
|
||||||
|
add subrequest 1 2 1
|
||||||
|
1
|
||||||
|
3
|
||||||
|
|
||||||
|
|
||||||
|
add thread 1
|
||||||
|
Signorina Silvani
|
||||||
|
4
|
||||||
|
4
|
||||||
|
3
|
||||||
|
add request 1 3
|
||||||
|
0
|
||||||
|
add subrequest 1 3 1
|
||||||
|
0
|
||||||
|
2
|
||||||
|
add subrequest 1 3 1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
run
|
Loading…
Reference in New Issue