diff --git a/Makefile.am b/Makefile.am
index bb381ff..5052c37 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -187,6 +187,7 @@ src_backend_libbackend_la_SOURCES = \
src/backend/serializer_error.cc \
src/backend/serializers_gatekeeper.cc \
src/backend/simulation.cc \
+ src/backend/simulation_observer.cc \
src/backend/static_process.cc \
src/backend/static_request.cc \
src/backend/static_resource.cc \
@@ -233,6 +234,7 @@ pkginclude_HEADERS += \
src/backend/serializer_error.hh \
src/backend/serializers_gatekeeper.hh \
src/backend/simulation.hh \
+ src/backend/simulation_observer.hh \
src/backend/sub_request.hh \
src/backend/thread.hh \
src/backend/user_interrupt_exception.hh
diff --git a/glade/configure-dialog.glade b/glade/configure-dialog.glade
index 5d4a7bd..39b3f5d 100644
--- a/glade/configure-dialog.glade
+++ b/glade/configure-dialog.glade
@@ -13,6 +13,7 @@
300
True
False
+ gtk-preferences
True
False
False
@@ -551,7 +552,7 @@
True
- True
+ False
0
@@ -651,31 +652,6 @@
-
- 0
- True
- True
-
-
-
-
-
- True
-
- False
- False
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
- PANGO_ELLIPSIZE_NONE
- -1
- False
- 0
-
0
False
diff --git a/glade/main-window.glade b/glade/main-window.glade
index d6b5e96..ce01c35 100644
--- a/glade/main-window.glade
+++ b/glade/main-window.glade
@@ -92,27 +92,6 @@
-
-
-
-
-
+
+
+
+
0
diff --git a/src/backend/concrete_simulation.cc b/src/backend/concrete_simulation.cc
index de78b49..e653639 100644
--- a/src/backend/concrete_simulation.cc
+++ b/src/backend/concrete_simulation.cc
@@ -19,6 +19,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "concrete_simulation.hh"
+#include "simulation_observer.hh"
#include "scheduler.hh"
#include "cpu_policies_gatekeeper.hh"
#include
@@ -27,6 +28,11 @@
#include "smartp.tcc"
+#include
+#include
+#include
+#include
+
using namespace std;
using namespace sgpem;
using namespace memory;
@@ -34,7 +40,10 @@ using Glib::usleep;
ConcreteSimulation::ConcreteSimulation() :
_state(state_stopped), _mode(true), _timer_interval(1000), _policy(NULL)
-{}
+{
+ _notify = false;
+ _front = 0;
+}
void
ConcreteSimulation::set_timer(unsigned int t)
@@ -60,6 +69,37 @@ ConcreteSimulation::get_mode() const
return _mode;
}
+void
+ConcreteSimulation::jump_to(History::position p)
+{
+
+ switch (_state)
+ {
+ case state_running:
+ pause();
+ break;
+ case state_stopped:
+ _history.reset(true);
+ _front = 0;
+ break;
+ default:
+ ;
+ }
+
+ pause();
+
+ bool yet_to_finish = true;
+ while (yet_to_finish && p > _front)
+ yet_to_finish = step();
+
+ if (!yet_to_finish)
+ stop();
+ _history.get_size() << std::endl;
+ _front = p < _front ? p : _front;
+ notify_change();
+}
+
+
void
ConcreteSimulation::pause()
{
@@ -81,6 +121,7 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException, Mal
return;
case state_stopped:
_history.reset(true);
+ _front = 0;
break;
default:
;
@@ -102,8 +143,12 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException, Mal
try
{
//step forward
- bool yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
+ bool yet_to_finish = true;
+ if (_front == get_history().get_size() - 1)
+ yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
if (!yet_to_finish) stop();
+ _front++;
+ notify_change();
//sleep
Glib::usleep(_timer_interval*1000);
@@ -128,7 +173,11 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException, Mal
{
assert(get_policy() != NULL);
//step forward
- bool yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
+ bool yet_to_finish = true;
+ if (_front == get_history().get_size() - 1)
+ yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
+ _front++;
+ notify_change();
if (yet_to_finish)
pause();
else
@@ -142,6 +191,34 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException, Mal
}
}
+bool
+ConcreteSimulation::step()
+ throw(UserInterruptException, NullPolicyException, MalformedPolicyException)
+{
+ if (get_policy() == NULL)
+ {
+ stop();
+ throw NullPolicyException("no policy selected");
+ }
+
+ try
+ {
+ assert(get_policy() != NULL);
+ //step forward
+ bool yet_to_finish = true;
+ if (_front == get_history().get_size() - 1)
+ yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
+ _front++;
+ return yet_to_finish;
+ }
+ catch (const CPUPolicyException& e)
+ {
+ stop();
+ throw;
+ }
+}
+
+
Simulation::state
ConcreteSimulation::get_state() const
{
@@ -154,6 +231,13 @@ ConcreteSimulation::get_history()
return _history;
}
+const ConcreteHistory&
+ConcreteSimulation::get_history() const
+{
+ return _history;
+}
+
+
void
ConcreteSimulation::set_policy(CPUPolicy* p) throw(CPUPolicyException)
{
diff --git a/src/backend/concrete_simulation.hh b/src/backend/concrete_simulation.hh
index 40c0ec9..b563a74 100644
--- a/src/backend/concrete_simulation.hh
+++ b/src/backend/concrete_simulation.hh
@@ -21,9 +21,16 @@
#ifndef CONCRETE_SIMULATION_HH
#define CONCRETE_SIMULATION_HH 1
+#include "config.h"
+
#include "simulation.hh"
#include "concrete_history.hh"
+#include