diff --git a/plugins/pyloader/sgpem.i b/plugins/pyloader/sgpem.i index 92be7b4..7e36373 100644 --- a/plugins/pyloader/sgpem.i +++ b/plugins/pyloader/sgpem.i @@ -145,7 +145,7 @@ namespace sgpem { // -------------------------------------------- - class SchedulableList + class SchedulableQueue { public: unsigned int size() const; @@ -154,10 +154,10 @@ namespace sgpem { private: // Avoid instantiation and copy - SchedulableList(); - SchedulableList(const SchedulableList&); - SchedulableList& operator=(const SchedulableList&); - ~SchedulableList(); + SchedulableQueue(); + SchedulableQueue(const SchedulableQueue&); + SchedulableQueue& operator=(const SchedulableQueue&); + ~SchedulableQueue(); }; //~ class Schedulable // --------------------------------------------- @@ -186,7 +186,7 @@ namespace sgpem { public: sgpem::Policy& get_policy(); static sgpem::Scheduler& get_instance(); - sgpem::SchedulableList* get_ready_queue(); + sgpem::SchedulableQueue* get_ready_queue(); private: Scheduler(); ~Scheduler(); diff --git a/plugins/pyloader/testsuite/test-python_loader.cc b/plugins/pyloader/testsuite/test-python_loader.cc index 6d0e165..eb0a2ad 100644 --- a/plugins/pyloader/testsuite/test-python_loader.cc +++ b/plugins/pyloader/testsuite/test-python_loader.cc @@ -104,7 +104,7 @@ main(int argc, char** argv) { try { - SchedulableList sl; + SchedulableQueue sl; polman.test_init("python_loader_sort_queue"); polman.get_policy().sort_queue(Scheduler::event_schedulable_arrival); } diff --git a/src/backend/history.cc b/src/backend/history.cc index 8a3d13e..2ca8d79 100644 --- a/src/backend/history.cc +++ b/src/backend/history.cc @@ -47,7 +47,7 @@ History::get_instance() /** Returns a pointer to a copy of the SchedulableStatus object relative to this instant. It can be NULL if time is out of range or if there are no running entities in the associated - SchedulableList + SchedulableQueue */ smart_ptr History::get_scheduled_at(int time) const @@ -56,7 +56,7 @@ History::get_scheduled_at(int time) const return smart_ptr(NULL); //look for a runing entity - smart_ptr p = get_simulation_status_at(time); + smart_ptr p = get_simulation_status_at(time); for (uint i = 0; i < p->size(); i++) if (p->get_item_at(i)->get_state() == SchedulableStatus::state_running) @@ -69,21 +69,21 @@ History::get_scheduled_at(int time) const Returns a pointer to a copy of the SimulationStatus object relative to this instant or NULL if time is out of range. */ -smart_ptr +smart_ptr History::get_simulation_status_at(int time) const { if (time > _total_time_elapsed || time < 0) //out of range - return smart_ptr(NULL); + return smart_ptr(NULL); int trascorso = -1; for(vector::const_iterator i=_slices.begin(); i < _slices.end(); i++) if (time <= trascorso + i->get_duration()) //FOUND!! - return smart_ptr(new SchedulableList(*i->get_simulation_status())); + return smart_ptr(new SchedulableQueue(*i->get_simulation_status())); else //Go on... trascorso += i->get_duration(); //never reached if all slices are CONTIGUOUS (ans THIS shoul be!!)!!! - return smart_ptr(NULL); + return smart_ptr(NULL); } int @@ -97,7 +97,7 @@ History::get_current_time() const Calls the method notify() in quality of ObservedSubject, updating all observers. */ void -History::enqueue_slice(const SchedulableList& status) +History::enqueue_slice(const SchedulableQueue& status) { if(_slices.size() == 0) { diff --git a/src/backend/history.hh b/src/backend/history.hh index 4eeb512..75ad052 100644 --- a/src/backend/history.hh +++ b/src/backend/history.hh @@ -62,7 +62,7 @@ namespace sgpem \param time The inquired time instant. \return The list of Schedulable status objects at the specified time. */ - virtual memory::smart_ptr get_simulation_status_at(int time) const; + virtual memory::smart_ptr get_simulation_status_at(int time) const; /** Gets the current time. @@ -74,7 +74,7 @@ namespace sgpem Sets the status of simulation at the current time. \param status The list of \ref Schedulable status objects at the current time. */ - virtual void enqueue_slice(const sgpem::SchedulableList& status); + virtual void enqueue_slice(const sgpem::SchedulableQueue& status); /** Remove all data in History following the specified time. diff --git a/src/backend/schedulable_list.cc b/src/backend/schedulable_list.cc index 2489fe4..4c24d4a 100644 --- a/src/backend/schedulable_list.cc +++ b/src/backend/schedulable_list.cc @@ -24,12 +24,12 @@ using namespace sgpem; using namespace std; using namespace memory; -SchedulableList::SchedulableList() +SchedulableQueue::SchedulableQueue() { } SchedulableStatus* -SchedulableList::top() +SchedulableQueue::top() { if (_list.size() == 0) return NULL; @@ -37,7 +37,7 @@ SchedulableList::top() } SchedulableStatus* -SchedulableList::bottom() +SchedulableQueue::bottom() { if (_list.size() == 0) return NULL; @@ -51,7 +51,7 @@ SchedulableList::bottom() DON'T call delete on the returned pointer! Its destruction is managed by the queue. */ SchedulableStatus* -SchedulableList::get_item_at(const uint& where) +SchedulableQueue::get_item_at(const uint& where) { if (_list.size() == 0 || where >= _list.size()) return NULL; @@ -63,7 +63,7 @@ SchedulableList::get_item_at(const uint& where) } const SchedulableStatus* -SchedulableList::get_item_at(const uint& where) const +SchedulableQueue::get_item_at(const uint& where) const { if (_list.size() == 0 || where >= _list.size()) return NULL; @@ -79,25 +79,25 @@ SchedulableList::get_item_at(const uint& where) const */ uint -SchedulableList::size() const +SchedulableQueue::size() const { return _list.size(); } void -SchedulableList::add_at_top(const SchedulableStatus& ss) +SchedulableQueue::add_at_top(const SchedulableStatus& ss) { _list.push_front(ss); } void -SchedulableList::add_at_bottom(const SchedulableStatus& ss) +SchedulableQueue::add_at_bottom(const SchedulableStatus& ss) { _list.push_back(ss); } smart_ptr -SchedulableList::remove(const uint& position) +SchedulableQueue::remove(const uint& position) { if (_list.size() == 0 || position >= _list.size()) return smart_ptr(NULL); @@ -114,7 +114,7 @@ SchedulableList::remove(const uint& position) */ bool -SchedulableList::insert_at(const uint& which, const uint& where) +SchedulableQueue::insert_at(const uint& which, const uint& where) { //out of range if (which >= _list.size() || where >= _list.size()) @@ -144,7 +144,7 @@ SchedulableList::insert_at(const uint& which, const uint& where) */ void -SchedulableList::clear() +SchedulableQueue::clear() { _list.clear(); } @@ -154,7 +154,7 @@ SchedulableList::clear() \brief Returns TRUE if the two objects have the same SchedulableStatus objects in the same order. */ bool -SchedulableList::operator==(const SchedulableList& dx) const +SchedulableQueue::operator==(const SchedulableQueue& dx) const { return _list == dx._list; } @@ -164,7 +164,7 @@ SchedulableList::operator==(const SchedulableList& dx) const \brief Returns TRUE if the two objects have the same SchedulableStatus objects with NO ORDER IMPORTANCE. */ bool -SchedulableList::has_same_objects(const SchedulableList& dx) const +SchedulableQueue::has_same_objects(const SchedulableQueue& dx) const { if (_list.size() != dx._list.size()) return false; @@ -179,7 +179,7 @@ SchedulableList::has_same_objects(const SchedulableList& dx) const void -SchedulableList::swap(unsigned int positionA, unsigned int positionB) throw() +SchedulableQueue::swap(unsigned int positionA, unsigned int positionB) throw() { if (positionA == positionB || positionA >= _list.size() || positionB >= _list.size()) return; diff --git a/src/backend/schedulable_list.hh b/src/backend/schedulable_list.hh index d3dfef5..f42226b 100644 --- a/src/backend/schedulable_list.hh +++ b/src/backend/schedulable_list.hh @@ -31,14 +31,14 @@ namespace sgpem { - class SchedulableList; + class SchedulableQueue; - class SG_DLLEXPORT SchedulableList + class SG_DLLEXPORT SchedulableQueue { public: - SchedulableList(); - bool operator==(const SchedulableList&) const; - bool has_same_objects(const SchedulableList& dx) const; + SchedulableQueue(); + bool operator==(const SchedulableQueue&) const; + bool has_same_objects(const SchedulableQueue& dx) const; /** \brief Returns a pointer to the first element * diff --git a/src/backend/scheduler.cc b/src/backend/scheduler.cc index 6471ff4..8086be0 100644 --- a/src/backend/scheduler.cc +++ b/src/backend/scheduler.cc @@ -46,7 +46,7 @@ Scheduler::get_instance() return *_instance; } -SchedulableList* +SchedulableQueue* Scheduler::get_ready_queue() { return &_ready_queue; @@ -90,7 +90,7 @@ Scheduler::step_forward() throw(UserInterruptException) //****************** //check for arrivals and prepare the queue //****************** - smart_ptr initial = h.get_simulation_status_at(h.get_current_time()); + smart_ptr initial = h.get_simulation_status_at(h.get_current_time()); if (!initial) { cout << _("\nNo initial state inserted!!\n"); diff --git a/src/backend/scheduler.hh b/src/backend/scheduler.hh index 58a99b4..85668ed 100644 --- a/src/backend/scheduler.hh +++ b/src/backend/scheduler.hh @@ -87,13 +87,13 @@ namespace sgpem \return a pointer to the queue containing all the ready schedulable objects (for the policy to sort it). */ - SchedulableList* get_ready_queue(); + SchedulableQueue* get_ready_queue(); /** Resets the simulation to the initial state. */ void reset_status(); /** - Generates a new SchedulableList representing the status of the processes + Generates a new SchedulableQueue representing the status of the processes at the simulation instant next to the current one, and extends the History by one instant with it. */ @@ -115,7 +115,7 @@ namespace sgpem private: Scheduler(); //private constructor. static Scheduler* _instance; - SchedulableList _ready_queue; + SchedulableQueue _ready_queue; PolicyManager& _policy_manager; }; diff --git a/src/backend/slice.cc b/src/backend/slice.cc index 4b95928..9e3a37b 100644 --- a/src/backend/slice.cc +++ b/src/backend/slice.cc @@ -23,12 +23,12 @@ using namespace sgpem; using namespace std; -Slice::Slice(const int& start, const int& duration, const SchedulableList& status) +Slice::Slice(const int& start, const int& duration, const SchedulableQueue& status) : _ref(status), _started_at(start), _duration(duration) { } -const SchedulableList* +const SchedulableQueue* Slice::get_simulation_status() const { return &_ref; diff --git a/src/backend/slice.hh b/src/backend/slice.hh index 1112aa9..8c96389 100644 --- a/src/backend/slice.hh +++ b/src/backend/slice.hh @@ -45,13 +45,13 @@ namespace sgpem \param duration Time length of Slice. \param status Photoshot of all \ref Schedulable during this Slice. */ - Slice(const int& start, const int& duration, const SchedulableList& status); + Slice(const int& start, const int& duration, const SchedulableQueue& status); /** - Gets a constant reference to the \ref SchedulableList object for this Slice. - \return The reference (constant) to the SchedulableList object for this Slice. + Gets a constant reference to the \ref SchedulableQueue object for this Slice. + \return The reference (constant) to the SchedulableQueue object for this Slice. */ - const SchedulableList* get_simulation_status() const; + const SchedulableQueue* get_simulation_status() const; /** @@ -73,7 +73,7 @@ namespace sgpem void set_duration(const int& duration); private: - SchedulableList _ref; + SchedulableQueue _ref; int _started_at; int _duration; }; diff --git a/src/main.cc b/src/main.cc index bbaa7df..0412390 100644 --- a/src/main.cc +++ b/src/main.cc @@ -119,7 +119,7 @@ main(int argc, char* argv[]) SchedulableStatus ss5(p5); SchedulableStatus ss6(p6); - SchedulableList initial; + SchedulableQueue initial; initial.add_at_bottom(ss1); initial.add_at_bottom(ss2); initial.add_at_bottom(ss3); @@ -151,17 +151,17 @@ main(int argc, char* argv[]) // ************** TEST HISTORY - SchedulableList l1; + SchedulableQueue l1; l1.add_at_top(ss1); l1.add_at_top(ss2); l1.add_at_top(ss3); - SchedulableList l2; + SchedulableQueue l2; l2.add_at_top(ss4); l2.add_at_top(ss5); l2.add_at_top(ss6); History h(History::get_instance()); h.enqueue_slice(l1); //stato iniziale h.enqueue_slice(l2); - smart_ptr quale; + smart_ptr quale; quale = h.get_simulation_status_at(0); //stato iniziale @@ -198,7 +198,7 @@ main(int argc, char* argv[]) //************** TEST QUEUE /* cout << "\n\nTEST QUEUE\n"; - SchedulableList sq; + SchedulableQueue sq; sq.add_at_bottom(ss1); sq.add_at_bottom(ss2); sq.add_at_bottom(ss3); diff --git a/src/simulation.cc b/src/simulation.cc index e0586f8..c50c492 100644 --- a/src/simulation.cc +++ b/src/simulation.cc @@ -98,7 +98,7 @@ Simulation::run() throw(UserInterruptException) do { // chech for termination bool all_term = true; - smart_ptr left = h.get_simulation_status_at(h.get_current_time()); + smart_ptr left = h.get_simulation_status_at(h.get_current_time()); for(uint i = 0; i < left->size(); i++) if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated) { @@ -141,7 +141,7 @@ Simulation::run() throw(UserInterruptException) { // chech for termination bool all_term = true; - smart_ptr left = h.get_simulation_status_at(h.get_current_time()); + smart_ptr left = h.get_simulation_status_at(h.get_current_time()); for(uint i = 0; i < left->size(); i++) if (left->get_item_at(i)->get_state() != SchedulableStatus::state_terminated) { diff --git a/src/testsuite/test-history.cc b/src/testsuite/test-history.cc index 14713b6..9c419da 100644 --- a/src/testsuite/test-history.cc +++ b/src/testsuite/test-history.cc @@ -45,7 +45,7 @@ using namespace std; class HistoryTester { public: - HistoryTester(SchedulableList sl) + HistoryTester(SchedulableQueue sl) : _history_length(-1), _internal_schedulable_list(sl) {} @@ -82,9 +82,9 @@ public: private: int _history_length; // mirrors the correct length of the history - SchedulableList* _get_simulation_status_at[400]; // mirrors the correct content of the history + SchedulableQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history SchedulableStatus* _get_scheduled_at[400]; // mirrors the correct content of the history - SchedulableList _internal_schedulable_list; + SchedulableQueue _internal_schedulable_list; // looks for anomalies @@ -113,13 +113,13 @@ public: } - // saves the given SchedulableList into the history, and saves a copy of it into an array - void _insert(sgpem::SchedulableList& status) + // saves the given SchedulableQueue into the history, and saves a copy of it into an array + void _insert(sgpem::SchedulableQueue& status) { History::get_instance().enqueue_slice(status); _history_length = _history_length + 1; - _get_simulation_status_at[_history_length] = new SchedulableList(status); + _get_simulation_status_at[_history_length] = new SchedulableQueue(status); if (History::get_instance().get_scheduled_at(_history_length) != memory::smart_ptr(NULL)) _get_scheduled_at[_history_length] = new SchedulableStatus(*(status.top())); @@ -129,8 +129,8 @@ public: } - // modifies the given SchedulableList object in an arbitrary way. - void _randomize(sgpem::SchedulableList& status) + // modifies the given SchedulableQueue object in an arbitrary way. + void _randomize(sgpem::SchedulableQueue& status) { status.swap(9, 10); status.swap(1, 16); @@ -232,7 +232,7 @@ main(int argc, char** argv) SchedulableStatus ss18(p18); SchedulableStatus ss19(p19); // not used! - SchedulableList initial; + SchedulableQueue initial; initial.add_at_bottom(ss1); initial.add_at_bottom(ss2); initial.add_at_bottom(ss3); diff --git a/src/testsuite/test-parse_command.cc b/src/testsuite/test-parse_command.cc index 4b8530d..96896a1 100644 --- a/src/testsuite/test-parse_command.cc +++ b/src/testsuite/test-parse_command.cc @@ -56,7 +56,7 @@ namespace sgpem std::cout << "get_scheduled_at" << time; return History::get_scheduled_at(time); } - memory::smart_ptr get_simulation_status_at(int time) const + memory::smart_ptr get_simulation_status_at(int time) const { std::cout << "get_simulation_status_at" << time; return History::get_simulation_status_at(time); @@ -66,7 +66,7 @@ namespace sgpem std::cout << "getCurrentTime"; return History::get_current_time(); } - void enqueue_slice(const sgpem::SchedulableList& status) + void enqueue_slice(const sgpem::SchedulableQueue& status) { std::cout << "enqueue_slice"; History::enqueue_slice(status); diff --git a/src/testsuite/test-stepforward.cc b/src/testsuite/test-stepforward.cc index c2aa52b..f87ebe2 100644 --- a/src/testsuite/test-stepforward.cc +++ b/src/testsuite/test-stepforward.cc @@ -82,7 +82,7 @@ namespace sgpem virtual void sort_queue(Scheduler::event event) const throw(UserInterruptException) { // here a lot of fun, exactly O(n^2) fun! - SchedulableList sl = History.get_instance().get_simulation_status_at(get_current_time()); + SchedulableQueue sl = History.get_instance().get_simulation_status_at(get_current_time()); for (int i = 0; i < sl.size(); i++) { for (int j = 0; j < sl.size()-1; j++) @@ -186,9 +186,9 @@ namespace sgpem public: memory::smart_ptr get_scheduled_at(int time) const {} - memory::smart_ptr get_simulation_status_at(int time) const; + memory::smart_ptr get_simulation_status_at(int time) const; int get_current_time() const {return _total_time_elapsed;} - void enqueue_slice(const sgpem::SchedulableList& status); + void enqueue_slice(const sgpem::SchedulableQueue& status); void truncate_at(int instant) {} static History& get_instance(); private: @@ -272,7 +272,7 @@ main(int argc, char** argv) { SchedulableStatus ss18(p18); SchedulableStatus ss19(p19); // not used! - SchedulableList initial; + SchedulableQueue initial; initial.add_at_bottom(ss1); initial.add_at_bottom(ss2); initial.add_at_bottom(ss3); diff --git a/src/text_simulation.cc b/src/text_simulation.cc index 64d4b7f..6672e1d 100644 --- a/src/text_simulation.cc +++ b/src/text_simulation.cc @@ -378,7 +378,7 @@ TextSimulation::update() ustring temp; when = h.get_current_time(); - smart_ptr ll = h.get_simulation_status_at(when); + smart_ptr ll = h.get_simulation_status_at(when); for (uint dev=0; dev < _devices.size(); dev++) {