- Substitute the old SchedulableQueue with the new ReadyQueue
- Add interfaces for Process and Thread into the "sgpem.i" SWIG interface file, change DynamicSchedulable into Schedulable - Add dynamic_cast for the return value of ReadyQueue::get_item_at() into the pyloader "sgpem.i" SWIG interface, so that a Schedulable can be either recognized as a Thread or a Process - TODO: wrap STL exceptions in SWIG interface - Please note that code won't compile until the new History and Scheduler::step_forward() will be in place. This is a known issue. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@689 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
fa06e2f4f1
commit
759b90b017
24 changed files with 170 additions and 414 deletions
|
@ -31,9 +31,9 @@ using namespace sgpem;
|
|||
smart_ptr<DynamicSchedulable> scheduled_at = smart_ptr<DynamicSchedulable>();
|
||||
if (0 <= time && time <= _total_time_elapsed)
|
||||
{
|
||||
smart_ptr<SchedulableQueue> sl = get_simulation_status_at(time);
|
||||
smart_ptr<ReadyQueue> sl = get_simulation_status_at(time);
|
||||
bool found = false;
|
||||
bool invalid = sl == smart_ptr<SchedulableQueue>();
|
||||
bool invalid = sl == smart_ptr<ReadyQueue>();
|
||||
for (uint i = 0; !found && !invalid && i < sl->size(); i++)
|
||||
{
|
||||
const DynamicSchedulable* ss = sl->get_item_at(i);
|
||||
|
@ -48,19 +48,19 @@ using namespace sgpem;
|
|||
}
|
||||
|
||||
|
||||
memory::smart_ptr<sgpem::SchedulableQueue>
|
||||
memory::smart_ptr<sgpem::ReadyQueue>
|
||||
History::get_simulation_status_at(int time) const
|
||||
{
|
||||
using namespace memory;
|
||||
smart_ptr<SchedulableQueue> simulation_status_at = smart_ptr<SchedulableQueue>();
|
||||
smart_ptr<ReadyQueue> simulation_status_at = smart_ptr<ReadyQueue>();
|
||||
if (0 <= time && time <= _total_time_elapsed)
|
||||
{
|
||||
if (_slice == memory::smart_ptr<Slice>())
|
||||
std::cout<<"History::get_simulation_status_at.NULL.error";
|
||||
else
|
||||
simulation_status_at = memory::smart_ptr<SchedulableQueue>
|
||||
simulation_status_at = memory::smart_ptr<ReadyQueue>
|
||||
(
|
||||
new SchedulableQueue
|
||||
new ReadyQueue
|
||||
(
|
||||
*(_slice->get_simulation_status())
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ using namespace sgpem;
|
|||
|
||||
|
||||
void
|
||||
History::enqueue_slice(const sgpem::SchedulableQueue& status)
|
||||
History::enqueue_slice(const sgpem::ReadyQueue& status)
|
||||
{
|
||||
_slice = memory::smart_ptr<Slice>(new Slice(_total_time_elapsed, 1, status));
|
||||
_total_time_elapsed++;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "backend/observed_subject.hh"
|
||||
#include "backend/slice.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "templates/smartp.tcc"
|
||||
#include <iostream>
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace sgpem
|
|||
|
||||
/** Returns the last recorded instant, but may raise an error.
|
||||
*/
|
||||
memory::smart_ptr<sgpem::SchedulableQueue>
|
||||
memory::smart_ptr<sgpem::ReadyQueue>
|
||||
get_simulation_status_at(int time) const;
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace sgpem
|
|||
/** Extends the recorded history by one unit, overwriting the old value
|
||||
*/
|
||||
void
|
||||
enqueue_slice(const sgpem::SchedulableQueue& status);
|
||||
enqueue_slice(const sgpem::ReadyQueue& status);
|
||||
|
||||
|
||||
/** STUB: THIS FEATURE IS NOT AVAILABLE
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
#include "backend/static_process.hh"
|
||||
#include "backend/observed_subject.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "backend/dynamic_schedulable.hh"
|
||||
#include "templates/smartp.tcc"
|
||||
#include "backend/user_interrupt_exception.hh"
|
||||
|
|
|
@ -53,7 +53,7 @@ PRRPolicy::configure()
|
|||
PRRPolicy::sort_queue() const
|
||||
throw(UserInterruptException)
|
||||
{
|
||||
SchedulableQueue* local_sl = Scheduler::get_instance().get_ready_queue();
|
||||
ReadyQueue* local_sl = Scheduler::get_instance().get_ready_queue();
|
||||
for (uint useless = 0; useless < local_sl->size(); useless++)
|
||||
for (uint i = 0; i < local_sl->size() - 1; i++)
|
||||
if
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "backend/policy.hh"
|
||||
#include "backend/user_interrupt_exception.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "backend/scheduler.hh"
|
||||
#include "glibmm/ustring.h"
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "backend/static_process.hh"
|
||||
#include "backend/slice.hh"
|
||||
#include "backend/observed_subject.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "backend/dynamic_schedulable.hh"
|
||||
|
||||
#include "templates/smartp.tcc"
|
||||
|
@ -54,8 +54,8 @@ class HistoryTester
|
|||
public:
|
||||
|
||||
|
||||
HistoryTester(SchedulableQueue sl)
|
||||
: _history_length(-1), _internal_schedulable_queue(sl)
|
||||
HistoryTester(ReadyQueue sl)
|
||||
: _history_length(-1), _internal_ready_queue(sl)
|
||||
{}
|
||||
|
||||
/** this method gets a sequence of operations as a parameter and performs them
|
||||
|
@ -73,10 +73,10 @@ public:
|
|||
switch(commands_sequence[i])
|
||||
{
|
||||
case 'E':
|
||||
_insert(_internal_schedulable_queue);
|
||||
_insert(_internal_ready_queue);
|
||||
break;
|
||||
case 'R':
|
||||
_randomize(_internal_schedulable_queue);
|
||||
_randomize(_internal_ready_queue);
|
||||
break;
|
||||
case 'T':
|
||||
_truncate();
|
||||
|
@ -92,9 +92,9 @@ public:
|
|||
private:
|
||||
|
||||
int _history_length; // mirrors the correct length of the history
|
||||
SchedulableQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history
|
||||
ReadyQueue* _get_simulation_status_at[400]; // mirrors the correct content of the history
|
||||
DynamicSchedulable* _get_scheduled_at[400]; // mirrors the correct content of the history
|
||||
SchedulableQueue _internal_schedulable_queue;
|
||||
ReadyQueue _internal_ready_queue;
|
||||
|
||||
|
||||
// looks for anomalies
|
||||
|
@ -131,13 +131,13 @@ private:
|
|||
}
|
||||
|
||||
|
||||
// saves the given SchedulableQueue into the history, and saves a copy of it into an array
|
||||
void _insert(sgpem::SchedulableQueue& status)
|
||||
// saves the given ReadyQueue into the history, and saves a copy of it into an array
|
||||
void _insert(sgpem::ReadyQueue& status)
|
||||
{
|
||||
History::get_instance().enqueue_slice(status);
|
||||
|
||||
_history_length = _history_length + 1;
|
||||
_get_simulation_status_at[_history_length] = new SchedulableQueue(status);
|
||||
_get_simulation_status_at[_history_length] = new ReadyQueue(status);
|
||||
|
||||
if (History::get_instance().get_scheduled_at(_history_length) != memory::smart_ptr<DynamicSchedulable>(NULL))
|
||||
_get_scheduled_at[_history_length] = new DynamicSchedulable(*(History::get_instance().get_scheduled_at(_history_length)));
|
||||
|
@ -147,8 +147,8 @@ private:
|
|||
}
|
||||
|
||||
|
||||
// modifies the given SchedulableQueue object in an arbitrary way.
|
||||
void _randomize(sgpem::SchedulableQueue& status)
|
||||
// modifies the given ReadyQueue object in an arbitrary way.
|
||||
void _randomize(sgpem::ReadyQueue& status)
|
||||
{
|
||||
status.swap(9, 10);
|
||||
status.swap(1, 16);
|
||||
|
@ -251,7 +251,7 @@ main(int argc, char** argv)
|
|||
DynamicSchedulable ss18(p18);
|
||||
DynamicSchedulable ss19(p19); // not used!
|
||||
|
||||
SchedulableQueue initial;
|
||||
ReadyQueue initial;
|
||||
initial.add_at_bottom(ss1);
|
||||
initial.add_at_bottom(ss2);
|
||||
initial.add_at_bottom(ss3);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "backend/static_process.hh"
|
||||
#include "backend/slice.hh"
|
||||
#include "backend/observed_subject.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "backend/dynamic_schedulable.hh"
|
||||
|
||||
#include "smartp.tcc"
|
||||
|
@ -57,7 +57,7 @@ namespace sgpem
|
|||
std::cout << "get_scheduled_at" << time;
|
||||
return History::get_scheduled_at(time);
|
||||
}
|
||||
memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const
|
||||
memory::smart_ptr<sgpem::ReadyQueue> get_simulation_status_at(int time) const
|
||||
{
|
||||
std::cout << "get_simulation_status_at" << time;
|
||||
return History::get_simulation_status_at(time);
|
||||
|
@ -67,7 +67,7 @@ namespace sgpem
|
|||
std::cout << "getCurrentTime";
|
||||
return History::get_current_time();
|
||||
}
|
||||
void enqueue_slice(const sgpem::SchedulableQueue& status)
|
||||
void enqueue_slice(const sgpem::ReadyQueue& status)
|
||||
{
|
||||
std::cout << "enqueue_slice";
|
||||
History::enqueue_slice(status);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <iostream>
|
||||
#include "backend/static_process.hh"
|
||||
#include "backend/observed_subject.hh"
|
||||
#include "backend/schedulable_queue.hh"
|
||||
#include "backend/ready_queue.hh"
|
||||
#include "backend/dynamic_schedulable.hh"
|
||||
|
||||
#include "scheduler.hh"
|
||||
|
@ -81,7 +81,7 @@ namespace sgpem
|
|||
|
||||
virtual void sort_queue() const throw(UserInterruptException)
|
||||
{ // here a lot of fun, exactly O(n^2) fun!
|
||||
SchedulableQueue sl = History.get_instance().get_simulation_status_at(get_current_time());
|
||||
ReadyQueue 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++)
|
||||
|
@ -184,9 +184,9 @@ namespace sgpem
|
|||
public:
|
||||
|
||||
memory::smart_ptr<sgpem::DynamicSchedulable> get_scheduled_at(int time) const {}
|
||||
memory::smart_ptr<sgpem::SchedulableQueue> get_simulation_status_at(int time) const;
|
||||
memory::smart_ptr<sgpem::ReadyQueue> get_simulation_status_at(int time) const;
|
||||
int get_current_time() const {return _total_time_elapsed;}
|
||||
void enqueue_slice(const sgpem::SchedulableQueue& status);
|
||||
void enqueue_slice(const sgpem::ReadyQueue& status);
|
||||
void truncate_at(int instant) {}
|
||||
static History& get_instance();
|
||||
private:
|
||||
|
@ -270,7 +270,7 @@ main(int argc, char** argv)
|
|||
DynamicSchedulable ss18(p18);
|
||||
DynamicSchedulable ss19(p19); // not used!
|
||||
|
||||
SchedulableQueue initial;
|
||||
ReadyQueue initial;
|
||||
initial.add_at_bottom(ss1);
|
||||
initial.add_at_bottom(ss2);
|
||||
initial.add_at_bottom(ss3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue