- fixed a number of bugs

- added dummy_policy written in C++
- the interpreter is now finished (hopefully)


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@366 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
fpaparel 2006-02-21 11:09:55 +00:00
parent ea70e2f092
commit 4482b98df7
17 changed files with 230 additions and 106 deletions

View File

@ -47,41 +47,41 @@ History::get_instance()
It can be NULL if time is out of range or if there are no running entities in the associated It can be NULL if time is out of range or if there are no running entities in the associated
SchedulableList SchedulableList
*/ */
smart_ptr<const SchedulableStatus> smart_ptr<SchedulableStatus>
History::get_scheduled_at(int time) const History::get_scheduled_at(int time) const
{ {
if (time >= _total_time_elapsed || time < 0) //out of range if (time > _total_time_elapsed || time < 0) //out of range
return smart_ptr<const SchedulableStatus>(NULL); return smart_ptr<SchedulableStatus>(NULL);
//look for a runing entity //look for a runing entity
smart_ptr<const SchedulableList> p = get_simulation_status_at(time); smart_ptr<SchedulableList> p = get_simulation_status_at(time);
for (uint i = 0; i < p->size(); i++) for (uint i = 0; i < p->size(); i++)
if (p->get_item_at(i)->get_state() == SchedulableStatus::state_running) if (p->get_item_at(i)->get_state() == SchedulableStatus::state_running)
return smart_ptr<const SchedulableStatus>(new SchedulableStatus(*(p->get_item_at(i)))); return smart_ptr<SchedulableStatus>(new SchedulableStatus(*(p->get_item_at(i))));
return smart_ptr<const SchedulableStatus>(NULL); return smart_ptr<SchedulableStatus>(NULL);
} }
/** /**
Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL
if time is out of range. if time is out of range.
*/ */
smart_ptr<const SchedulableList> smart_ptr<SchedulableList>
History::get_simulation_status_at(int time) const History::get_simulation_status_at(int time) const
{ {
if (time > _total_time_elapsed || time < 0) //out of range if (time > _total_time_elapsed || time < 0) //out of range
return smart_ptr<const SchedulableList>(NULL); return smart_ptr<SchedulableList>(NULL);
int trascorso = -1; int trascorso = -1;
for(vector<Slice>::const_iterator i=_slices.begin(); i < _slices.end(); i++) for(vector<Slice>::const_iterator i=_slices.begin(); i < _slices.end(); i++)
if (time <= trascorso + i->get_duration()) //FOUND!! if (time <= trascorso + i->get_duration()) //FOUND!!
return smart_ptr<const SchedulableList>(new SchedulableList(*i->get_simulation_status())); return smart_ptr<SchedulableList>(new SchedulableList(*i->get_simulation_status()));
else //Go on... else //Go on...
trascorso += i->get_duration(); trascorso += i->get_duration();
//never reached if all slices are CONTIGUOUS (ans THIS shoul be!!)!!! //never reached if all slices are CONTIGUOUS (ans THIS shoul be!!)!!!
return smart_ptr<const SchedulableList>(NULL); return smart_ptr<SchedulableList>(NULL);
} }
int int
@ -100,7 +100,7 @@ History::enqueue_slice(const SchedulableList& status)
if(_slices.size() == 0) if(_slices.size() == 0)
{ {
_slices.push_back(Slice(-1, 1, status)); _slices.push_back(Slice(-1, 1, status));
_total_time_elapsed = 1; _total_time_elapsed++;
notify(); notify();
return; return;
} }

View File

@ -51,8 +51,8 @@ namespace sgpem
{ {
public: public:
memory::smart_ptr<const sgpem::SchedulableStatus> get_scheduled_at(int time) const; memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const;
memory::smart_ptr<const sgpem::SchedulableList> get_simulation_status_at(int time) const; memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
int get_current_time() const; int get_current_time() const;
void enqueue_slice(const sgpem::SchedulableList& status); void enqueue_slice(const sgpem::SchedulableList& status);
void truncate_at(int instant); void truncate_at(int instant);

View File

@ -34,7 +34,8 @@ void
ObservedSubject::notify() ObservedSubject::notify()
{ {
for(vector<Observer*>::iterator i = _attached.begin(); i < _attached.end(); i++) for(vector<Observer*>::iterator i = _attached.begin(); i < _attached.end(); i++)
(*i)->update(); (*i)->update();
} }
/** /**

View File

@ -34,8 +34,8 @@ Policy::get_id() const
} }
const PolicyParameters& PolicyParameters&
Policy::get_parameters() const Policy::get_parameters()
{ {
return _parameters; return _parameters;
} }

View File

@ -22,6 +22,7 @@
#define POLICY_HH 1 #define POLICY_HH 1
#include "config.h" #include "config.h"
#include "gettext.h"
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
@ -50,16 +51,15 @@ namespace sgpem
virtual int get_time_slice() const = 0; virtual int get_time_slice() const = 0;
virtual void set_time_slice(const int&) = 0; virtual void set_time_slice(const int&) = 0;
const PolicyParameters& get_parameters() const; PolicyParameters& get_parameters();
private: protected:
PolicyParameters _parameters; PolicyParameters _parameters;
int _id; int _id;
}; };
}//~ namespace sgpem }//~ namespace sgpem
#endif #endif

View File

@ -134,7 +134,7 @@ SchedulableList::remove(const uint& position)
} }
/** /**
Switches two elements in the queue. Returns FALSE if one of the indexes is out of range.
*/ */
bool bool
SchedulableList::insert_at(const uint& which, const uint& where) SchedulableList::insert_at(const uint& which, const uint& where)

View File

@ -75,29 +75,46 @@ Scheduler::get_policy()
void void
Scheduler::step_forward() Scheduler::step_forward()
{ {
History& h = History::get_instance(); History& h = History::get_instance();
//****************** //******************
//check for arrivals and prepare the queue //check for arrivals and prepare the queue
//****************** //******************
smart_ptr<const SchedulableList> initial = h.get_simulation_status_at(h.get_current_time()); smart_ptr<SchedulableList> initial = h.get_simulation_status_at(h.get_current_time());
if (!initial)
{
cout << _("\nNo initial state inserted!!\n");
return;
}
_ready_queue.clear(); _ready_queue.clear();
//adds running schedulable //adds running schedulable
smart_ptr<const SchedulableStatus> running_ptr = h.get_scheduled_at(h.get_current_time()); smart_ptr<SchedulableStatus> running_ptr = h.get_scheduled_at(h.get_current_time());
if (running_ptr) if (running_ptr)
_ready_queue.add_at_top(*running_ptr); _ready_queue.add_at_top(*running_ptr);
//adds the READY ones
for(uint rea=0; rea < initial->size(); rea++)
if (initial->get_item_at(rea)->get_state() == SchedulableStatus::state_ready)
_ready_queue.add_at_bottom(*initial->get_item_at(rea));
//adds each new ready schedulable and sorts the queue //adds each new ready schedulable and sorts the queue
for(uint i=0; i < initial->size(); i++) for(uint i=0; i < initial->size(); i++)
if (initial->get_item_at(i)->get_state() == SchedulableStatus::state_ready if (initial->get_item_at(i)->get_state() == SchedulableStatus::state_future
&& (int)initial->get_item_at(i)->get_schedulable()->get_arrival_time() == h.get_current_time()) && (int)initial->get_item_at(i)->get_schedulable()->get_arrival_time() == h.get_current_time())
{ {
_ready_queue.add_at_bottom(*initial->get_item_at(i)); //cout << "\nnuovo running: " << initial->get_item_at(i)->get_schedulable()->get_name();
//pops the running schedulable only if the policy is not preemptive //restore the old running schedulable
if (_policy->is_pre_emptive() == false && running_ptr) if (_policy->is_pre_emptive() == false && running_ptr)
_ready_queue.remove(0); _ready_queue.remove(0);
//adds the NEW one
_ready_queue.add_at_bottom(*initial->get_item_at(i));
_ready_queue.get_item_at(_ready_queue.size()-1)->set_state(SchedulableStatus::state_ready);
initial->get_item_at(i)->set_state(SchedulableStatus::state_ready);
// Sort the queue // Sort the queue
_policy->sort_queue(event_schedulable_arrival); _policy->sort_queue(event_schedulable_arrival);
@ -106,22 +123,27 @@ Scheduler::step_forward()
_ready_queue.add_at_top(*running_ptr); _ready_queue.add_at_top(*running_ptr);
} }
//**************** //****************
// Check for termination // Check for termination
//**************** //****************
if (running_ptr && running_ptr->get_cpu_time_left() == 0) if (running_ptr && running_ptr->get_cpu_time_left() == 0)
{ {
//there was a running schedulable and it's terminated. Remove it! //there is a running schedulable and it's terminated. Append at the bottom with the state TERMINATED
for(uint i=0; i < _ready_queue.size(); i++) for(uint i=0; i < _ready_queue.size(); i++)
if (*_ready_queue.get_item_at(i) == *running_ptr) if (*_ready_queue.get_item_at(i) == *running_ptr)
{ {
_ready_queue.add_at_bottom(*_ready_queue.get_item_at(i));
_ready_queue.remove(i); _ready_queue.remove(i);
_ready_queue.get_item_at(_ready_queue.size()-1)->set_state(SchedulableStatus::state_terminated);
break; break;
} }
//cout << "\nTERMINATO!!";
running_ptr = NULL;
//IF _ready_queue.size() == 0 sort_queue(...) is called but has no effect!! //IF _ready_queue.size() == 0 sort_queue(...) is called but has no effect!!
_policy->sort_queue(event_schedulable_termination); _policy->sort_queue(event_schedulable_termination);
} }
//***************** //*****************
@ -134,30 +156,31 @@ Scheduler::step_forward()
// Create the final list of schedulable // Create the final list of schedulable
//****************** //******************
SchedulableList final = _ready_queue;
if (_ready_queue.size() != 0 && (_ready_queue.get_item_at(0)->get_state() == SchedulableStatus::state_ready
if (final.size() != 0) || _ready_queue.get_item_at(0)->get_state() == SchedulableStatus::state_running))
//the firs element IS the running one (if != *running_ptr then there is a CONTEXT SWICH) {
final.get_item_at(0)->set_state(SchedulableStatus::state_running); //the first ready element IS the running one (if != *running_ptr then there is a CONTEXT SWICH)
_ready_queue.get_item_at(0)->set_state(SchedulableStatus::state_running);
_ready_queue.get_item_at(0)->give_cpu_time(1);
}
//all the others are ready //all the others are ready
for (uint i = 1; i < final.size(); i++) for (uint i = 1; i < _ready_queue.size(); i++)
if (final.get_item_at(i)->get_state() == SchedulableStatus::state_running) if (_ready_queue.get_item_at(i)->get_state() == SchedulableStatus::state_running)
final.get_item_at(i)->set_state(SchedulableStatus::state_ready); _ready_queue.get_item_at(i)->set_state(SchedulableStatus::state_ready);
//append blocked, future, terminated and the old running schedulables //append blocked, future, and terminated schedulables
for (uint i = 0; i < initial->size(); i++) for (uint i = 0; i < initial->size(); i++)
if(initial->get_item_at(i)->get_state() == SchedulableStatus::state_blocked if(initial->get_item_at(i)->get_state() == SchedulableStatus::state_blocked
|| initial->get_item_at(i)->get_state() == SchedulableStatus::state_future || initial->get_item_at(i)->get_state() == SchedulableStatus::state_future
|| initial->get_item_at(i)->get_state() == SchedulableStatus::state_terminated || initial->get_item_at(i)->get_state() == SchedulableStatus::state_terminated)
|| (initial->get_item_at(i)->get_state() == SchedulableStatus::state_ready _ready_queue.add_at_bottom(*initial->get_item_at(i));
&& (int)initial->get_item_at(i)->get_schedulable()->get_arrival_time() != h.get_current_time()) )
final.add_at_bottom(*initial->get_item_at(i)); cout << "\n";
/* for (uint i = 0; i < _ready_queue.size(); i++)
h.enqueue_slice(final); cout << " " << _ready_queue.get_item_at(i)->get_schedulable()->get_name()
<<"_" << _ready_queue.get_item_at(i)->get_state();
*/
h.enqueue_slice(_ready_queue);
} }

View File

@ -28,7 +28,7 @@ namespace sgpem
#include "config.h" #include "config.h"
#include <limits> #include <limits>
#include <iostream>
#include "observed_subject.hh" #include "observed_subject.hh"
#include "history.hh" #include "history.hh"

View File

@ -60,4 +60,3 @@ namespace sgpem {
} }
#endif #endif

View File

@ -27,7 +27,6 @@
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
namespace sgpem { namespace sgpem {
class IOManager; class IOManager;
@ -39,23 +38,21 @@ namespace sgpem {
public: public:
virtual ~IOManager() {} virtual ~IOManager() {}
/**Writes a string into an output (the console, a text widget, ...) /**Writes a string into an output (the console, a text widget, ...)
\returns the number of charaters written \returns the number of charaters written
*/ */
virtual unsigned int write_buffer(const Glib::ustring& buffer) = 0; virtual uint write_buffer(const Glib::ustring& buffer) = 0;
/**Reads a command from an interactive input (the console, a text widget, ...) /**Reads a command from an interactive input (the console, a text widget, ...)
\returns a trimmed string (without blank spaces, tabs... at the extremities) \returns a trimmed string (without blank spaces, tabs... at the extremities)
*/ */
virtual Glib::ustring read_command() = 0; virtual Glib::ustring read_command() = 0;
/**Specify whether this IOManger permits to write and read at the same time /**Specify whether this IOManger permits to write and read at the same time
*/ */
virtual bool is_full_duplex() = 0; virtual bool is_full_duplex() = 0;
}; };
} }
#endif #endif

View File

@ -34,9 +34,13 @@
#include "backend/process.hh" #include "backend/process.hh"
#include "backend/policy.hh" #include "backend/policy.hh"
#include "backend/policy_parameters.hh" #include "backend/policy_parameters.hh"
#include "backend/python_policy.hh"
#include "backend/python_policy_manager.hh"
#include "standard_io.hh" #include "standard_io.hh"
#include "text_simulation.hh" #include "text_simulation.hh"
#include "backend/dummy_policy.hh"
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include <iostream> #include <iostream>
@ -72,32 +76,55 @@ main(int argc, char* argv[])
filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count); filenames.insert(filenames.begin(), a_ptr, a_ptr+a_count);
} }
*/ */
// Set the unique POLICY
DummyPolicy pol;
pol.configure();
pol.get_parameters().set_int("var2", 33);
pol.get_parameters().set_float("multiplier", 100);
pol.get_parameters().set_string("che_ne_so", "ciao");
Scheduler::get_instance().set_policy(&pol);
TextSimulation text_sim; TextSimulation text_sim;
History::get_instance().attach(&text_sim);
//textual IO //textual IO
smart_ptr<IOManager> io(new StandardIO()); smart_ptr<IOManager> io(new StandardIO());
text_sim.add_io_device(io); text_sim.add_io_device(io);
//grafical IO
start_gui(argc, argv); // Create an INITIAL STATE
Process p1("P1", 0,5,1);
//SMOKE-TEST for backend classes Process p2("P2", 0,5,2);
/* cout << "\n\n********************************"; Process p3("P3", 5,3,3);
Process p1("P1", 0,10,1); Process p4("P4", 6,2,3);
Process p2("P2", 0,30,2); Process p5("P5", 1,2,3);
Process p3("P3", 5,15,3);
Process p4("P4", 6,5,3);
Process p5("P5", 1,10,3);
Process p6("P6", 10,2,1); Process p6("P6", 10,2,1);
SchedulableStatus ss1(p1); ss1.set_state(SchedulableStatus::state_running); SchedulableStatus ss1(p1);
SchedulableStatus ss2(p2); SchedulableStatus ss2(p2);
SchedulableStatus ss3(p3); SchedulableStatus ss3(p3);
SchedulableStatus ss4(p4); ss4.set_state(SchedulableStatus::state_running); SchedulableStatus ss4(p4);
SchedulableStatus ss5(p5); SchedulableStatus ss5(p5);
SchedulableStatus ss6(p6); SchedulableStatus ss6(p6);
// SimulationStatus sim1; sim1.set_running(p1); SchedulableList initial;
initial.add_at_bottom(ss1);
initial.add_at_bottom(ss2);
initial.add_at_bottom(ss3);
initial.add_at_bottom(ss4);
initial.add_at_bottom(ss5);
initial.add_at_bottom(ss6);
History::get_instance().enqueue_slice(initial);
//grafical IO
start_gui(argc, argv);
//SMOKE-TEST for backend classes
/* cout << "\n\n********************************";
//************** TEST HISTORY //************** TEST HISTORY
@ -170,4 +197,3 @@ main(int argc, char* argv[])
*/ */
return 0; return 0;
} }

View File

@ -25,7 +25,7 @@ using namespace sgpem;
using namespace memory; using namespace memory;
using Glib::usleep; using Glib::usleep;
Simulation::Simulation(): _state(state_paused), _mode(false), _timer_interval(1000) Simulation::Simulation(): _state(state_paused), _mode(true), _timer_interval(1000)
{ {
} }
@ -83,16 +83,17 @@ Simulation::run()
_state = state_running; _state = state_running;
//******* CONTINUOUS TIME //******* CONTINUOUS TIME
if (_mode) if (_mode)
{ {
loop: loop:
// chech for termination // chech for termination
bool all_term = true; bool all_term = true;
smart_ptr<const SchedulableList> left = h.get_simulation_status_at(h.get_current_time()); smart_ptr<SchedulableList> left = h.get_simulation_status_at(h.get_current_time());
for(uint i = 0; i < left->size(); i++) for(uint i = 0; i < left->size(); i++)
if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated) if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated)
{ {
all_term = true; all_term = false;
break; break;
} }
@ -119,14 +120,14 @@ Simulation::run()
//******* STEP by STEP //******* STEP by STEP
else else
{ {
// chech for termination // chech for termination
bool all_term = true; bool all_term = true;
smart_ptr<const SchedulableList> left = h.get_simulation_status_at(h.get_current_time()); smart_ptr<SchedulableList> left = h.get_simulation_status_at(h.get_current_time());
for(uint i = 0; i < left->size(); i++) for(uint i = 0; i < left->size(); i++)
if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated) if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated)
{ {
all_term = true; all_term = false;
break; break;
} }
@ -178,4 +179,3 @@ Simulation::get_avaiable_policies()
v.push_back(Scheduler::get_instance().get_policy()); v.push_back(Scheduler::get_instance().get_policy());
return v; return v;
} }

View File

@ -76,4 +76,3 @@ namespace sgpem
#endif #endif

View File

@ -61,4 +61,3 @@ StandardIO::is_full_duplex()
{ {
return false; return false;
} }

View File

@ -49,4 +49,3 @@ namespace sgpem {
} }
#endif #endif

View File

@ -95,7 +95,7 @@ check:
" depending the mode configured with SetMode (default=continuous)")); " depending the mode configured with SetMode (default=continuous)"));
return; return;
} }
obj->_devices[quale]->write_buffer("\n\tRUN!!"); obj->run();
} }
else if (arguments[param] == "PAUSE") else if (arguments[param] == "PAUSE")
{ {
@ -105,7 +105,7 @@ check:
"\n-- PAUSE COMMAND --\nPauses the simulation. The next call to RUN will restart it.")); "\n-- PAUSE COMMAND --\nPauses the simulation. The next call to RUN will restart it."));
return; return;
} }
obj->_devices[quale]->write_buffer("\n\tPAUSE!!"); obj->pause();
} }
else if (arguments[param] == "STOP") else if (arguments[param] == "STOP")
{ {
@ -116,7 +116,7 @@ check:
"bring the simulation to the FIRST instant and start it.")); "bring the simulation to the FIRST instant and start it."));
return; return;
} }
obj->_devices[quale]->write_buffer("\n\tSTOP!!"); obj->stop();
} }
else if (arguments[param] == "RESET") else if (arguments[param] == "RESET")
{ {
@ -126,8 +126,7 @@ check:
"\n-- RESET COMMAND --\nResets the simulation jumping back to the first instant.")); "\n-- RESET COMMAND --\nResets the simulation jumping back to the first instant."));
return; return;
} }
obj->_devices[quale]->write_buffer("\n\tRESET!!"); obj->reset();
} }
else if (arguments[param] == "QUIT") else if (arguments[param] == "QUIT")
{ {
@ -145,7 +144,8 @@ check:
if (show_help) if (show_help)
{ {
obj->_devices[quale]->write_buffer(_( obj->_devices[quale]->write_buffer(_(
"\n-- YOU ARE JOKING ME --\nYou're really too dummy!!!\n")); "\n-- Do you really want me to explain what HELP means? --"
"\n ************** YOU ARE JOKING ME !!! ************\n\n"));
exit(1); exit(1);
} }
if (arguments.size() == 1) if (arguments.size() == 1)
@ -293,13 +293,31 @@ check:
int_to_string(i_i->second.get_value(), temp); int_to_string(i_i->second.get_value(), temp);
obj->_devices[quale]->write_buffer("\tvalue=" + temp); obj->_devices[quale]->write_buffer("\tvalue=" + temp);
int_to_string(i_i->second.get_lower_bound(), temp); int_to_string(i_i->second.get_lower_bound(), temp);
obj->_devices[quale]->write_buffer(" lower=" + temp); obj->_devices[quale]->write_buffer("\t\tlower=" + temp);
int_to_string(i_i->second.get_upper_bound(), temp); int_to_string(i_i->second.get_upper_bound(), temp);
obj->_devices[quale]->write_buffer(" upper=" + temp); obj->_devices[quale]->write_buffer("\t\tupper=" + temp);
if (i_i->second.is_required()) if (i_i->second.is_required())
obj->_devices[quale]->write_buffer(" required=true"); obj->_devices[quale]->write_buffer("\t\trequired=true");
else else
obj->_devices[quale]->write_buffer(" required=false"); obj->_devices[quale]->write_buffer("\t\trequired=false");
}
map<ustring, PolicyParameters::Parameter<float> > map_f = param.get_registered_float_parameters();
map<ustring, PolicyParameters::Parameter<float> >::iterator i_f = map_f.begin();
for(; i_f != map_f.end(); i_f++)
{
obj->_devices[quale]->write_buffer("\nfloat\t" + i_f->second.get_name());
float_to_string(i_f->second.get_value(), temp);
obj->_devices[quale]->write_buffer("\tvalue=" + temp);
float_to_string(i_f->second.get_lower_bound(), temp);
obj->_devices[quale]->write_buffer("\t\tlower=" + temp);
float_to_string(i_f->second.get_upper_bound(), temp);
obj->_devices[quale]->write_buffer("\t\tupper=" + temp);
if (i_f->second.is_required())
obj->_devices[quale]->write_buffer("\t\trequired=true");
else
obj->_devices[quale]->write_buffer("\t\trequired=false");
} }
map<ustring, PolicyParameters::Parameter<ustring> > map_s = param.get_registered_string_parameters(); map<ustring, PolicyParameters::Parameter<ustring> > map_s = param.get_registered_string_parameters();
@ -314,11 +332,13 @@ check:
else else
obj->_devices[quale]->write_buffer(" required=false"); obj->_devices[quale]->write_buffer(" required=false");
} }
} }
else else
{ {
obj->_devices[quale]->write_buffer("\nCommand not recognized: "); obj->_devices[quale]->write_buffer(_("\nCommand not recognized: "));
obj->_devices[quale]->write_buffer(arguments[param]); obj->_devices[quale]->write_buffer(arguments[param]);
obj->_devices[quale]->write_buffer(_("\nTyper HELP for a list of avaiable commands."));
return; return;
} }
} }
@ -327,7 +347,69 @@ check:
void void
TextSimulation::update() TextSimulation::update()
{ {
History& h = History::get_instance();
int when, pri;
ustring temp;
when = h.get_current_time();
smart_ptr<SchedulableList> ll = h.get_simulation_status_at(when);
int_to_string(when, temp);
if (when<10)
_devices[0]->write_buffer("\n ");
else
_devices[0]->write_buffer("\n");
_devices[0]->write_buffer(temp + ") [RUNS]");
//insert the RUNNING ONE
smart_ptr<SchedulableStatus> running = h.get_scheduled_at(when);
if (running)
{
pri = running->get_schedulable()->get_priority();
int_to_string(pri, temp);
_devices[0]->write_buffer(" " + running->get_schedulable()->get_name() + "_(" + temp + ")");
}
_devices[0]->write_buffer(" --[READY]");
//insert the READY ones
for (uint i = 0; i < ll->size(); i++)
if (ll->get_item_at(i)->get_state() == SchedulableStatus::state_ready)
{
pri = ll->get_item_at(i)->get_schedulable()->get_priority();
int_to_string(pri, temp);
_devices[0]->write_buffer(" " + ll->get_item_at(i)->get_schedulable()->get_name() + "_(" + temp + ")");
}
_devices[0]->write_buffer(" --[BLOCKED]");
//insert the BLOCKED ones
for (uint i = 0; i < ll->size(); i++)
if (ll->get_item_at(i)->get_state() == SchedulableStatus::state_blocked)
{
pri = ll->get_item_at(i)->get_schedulable()->get_priority();
int_to_string(pri, temp);
_devices[0]->write_buffer(" " + ll->get_item_at(i)->get_schedulable()->get_name() + "_(" + temp + ")");
}
_devices[0]->write_buffer(" --[FUTURE]");
//insert the FUTURE ones
for (uint i = 0; i < ll->size(); i++)
if (ll->get_item_at(i)->get_state() == SchedulableStatus::state_future)
{
pri = ll->get_item_at(i)->get_schedulable()->get_priority();
int_to_string(pri, temp);
_devices[0]->write_buffer(" " + ll->get_item_at(i)->get_schedulable()->get_name() + "_(" + temp + ")");
}
_devices[0]->write_buffer(" --[TERM]");
//insert the TERMINATED ones
for (uint i = 0; i < ll->size(); i++)
if (ll->get_item_at(i)->get_state() == SchedulableStatus::state_terminated)
{
pri = ll->get_item_at(i)->get_schedulable()->get_priority();
int_to_string(pri, temp);
_devices[0]->write_buffer(" " + ll->get_item_at(i)->get_schedulable()->get_name() + "_(" + temp + ")");
}
} }
void void
@ -351,4 +433,3 @@ TextSimulation::_io_loop(pair<TextSimulation* , int > pun)
pun.first->parse_command(p); pun.first->parse_command(p);
} }
} }

View File

@ -60,4 +60,4 @@ namespace sgpem
} }
#endif #endif