Fix compilation warnings and a couple of errors due to GCC -pedantic flags

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1329 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2008-11-08 21:17:11 +00:00
parent 61df7cd551
commit 99135b1237
39 changed files with 77 additions and 188 deletions

View File

@ -501,7 +501,9 @@ src_testsuite_test_statistics_LDFLAGS = \
src_testsuite_test_statistics_SOURCES = \ src_testsuite_test_statistics_SOURCES = \
src/backend/statistics.cc \ src/backend/statistics.cc \
src/backend/concrete_process_statistics.cc \ src/backend/concrete_process_statistics.cc \
src/backend/concrete_thread_statistics.cc \
src/backend/concrete_simulation_statistics.cc \ src/backend/concrete_simulation_statistics.cc \
src/backend/concrete_statistics.cc \
src/testsuite/test-statistics.cc src/testsuite/test-statistics.cc

View File

@ -240,11 +240,10 @@ $ac_distutils_result])
LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
AC_LANG_PUSH([C]) AC_LANG_PUSH([C])
AC_TRY_LINK(AC_LANG_PROGRAM([ AC_LINK_IFELSE([
#include <Python.h> AC_LANG_PROGRAM([[#include <Python.h>]],
],[ [[Py_Initialize();]])
Py_Initialize(); ],[pythonexists=yes],[pythonexists=no])
]),[pythonexists=yes],[pythonexists=no])
AC_LANG_POP([C]) AC_LANG_POP([C])
# turn back to default flags # turn back to default flags
CPPFLAGS="$ac_save_CPPFLAGS" CPPFLAGS="$ac_save_CPPFLAGS"

View File

@ -91,12 +91,12 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
PythonCPUPolicy::~PythonCPUPolicy() PythonCPUPolicy::~PythonCPUPolicy()
{ {
if (_adapter) Py_DECREF(_adapter); if (_adapter) { Py_DECREF(_adapter); }
// We keep this alive until dtor time, because // We keep this alive until dtor time, because
// the user may have defined some static global-space // the user may have defined some static global-space
// variables and they make use of them. // variables and they make use of them.
if (_upolicy_dict) Py_DECREF(_upolicy_dict); if (_upolicy_dict) { Py_DECREF(_upolicy_dict); }
} }
void void
@ -135,7 +135,7 @@ PythonCPUPolicy::configure() throw(UserInterruptException, MalformedPolicyExcept
Glib::RecMutex::Lock lock(_mtx);; Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this)); set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, "async_configure", NULL); PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_configure"), NULL);
Py_DECREF(retval); Py_DECREF(retval);
wait_unlock(); wait_unlock();
@ -150,7 +150,7 @@ PythonCPUPolicy::sort_queue() const throw(UserInterruptException, MalformedPolic
Glib::RecMutex::Lock lock(_mtx);; Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this)); set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL); PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_sort_queue"), NULL);
// Do minimal debugging // Do minimal debugging
if (!retval) PyErr_Print(); if (!retval) PyErr_Print();
@ -181,13 +181,13 @@ PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException, MalformedP
Glib::RecMutex::Lock lock(_mtx);; Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this)); set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, "async_is_preemptive", NULL); PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_is_preemptive"), NULL);
Py_DECREF(retval); Py_DECREF(retval);
wait_unlock(); wait_unlock();
// Parse return value stored in global Python object // Parse return value stored in global Python object
retval = PyObject_CallMethod(_adapter, "get_return_value", NULL); retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
assert(retval); assert(retval);
bool ret = PyObject_IsTrue(retval); bool ret = PyObject_IsTrue(retval);
Py_DECREF(retval); Py_DECREF(retval);
@ -203,7 +203,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
Glib::RecMutex::Lock lock(_mtx);; Glib::RecMutex::Lock lock(_mtx);;
set_callback_policy(const_cast<PythonCPUPolicy*>(this)); set_callback_policy(const_cast<PythonCPUPolicy*>(this));
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL); PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_get_time_slice"), NULL);
// Do minimal debugging // Do minimal debugging
if (!retval) PyErr_Print(); if (!retval) PyErr_Print();
@ -212,7 +212,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
wait_unlock(); wait_unlock();
// Parse return value stored in global Python object // Parse return value stored in global Python object
retval = PyObject_CallMethod(_adapter, "get_return_value", NULL); retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
assert(retval); assert(retval);
long tmp = PyInt_AsLong(retval); long tmp = PyInt_AsLong(retval);
Py_DECREF(retval); Py_DECREF(retval);
@ -239,7 +239,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
Glib::usleep(wait_for); // hack'a'ton! magggggiccc nummmbeeerrrrrs!! Glib::usleep(wait_for); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS; Py_BLOCK_THREADS;
PyObject* retval = PyObject_CallMethod(_adapter, "mutex_test_lock", NULL); PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("mutex_test_lock"), NULL);
assert(retval); assert(retval);
still_locked = PyObject_IsTrue(retval); still_locked = PyObject_IsTrue(retval);
Py_DECREF(retval); Py_DECREF(retval);
@ -263,7 +263,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
// check if there were unhandled exception in the user-defined code // check if there were unhandled exception in the user-defined code
PyObject* pException = PyObject_CallMethod(_adapter, "get_last_exception", NULL); PyObject* pException = PyObject_CallMethod(_adapter, const_cast<char*>("get_last_exception"), NULL);
if(pException != NULL) if(pException != NULL)
{ {
@ -325,9 +325,9 @@ PythonCPUPolicy::get_exception_information()
else else
msg = string(_("no available information for this error")); msg = string(_("no available information for this error"));
if (pType != NULL) Py_DECREF(pType); if (pType != NULL) { Py_DECREF(pType); }
if (pValue != NULL) Py_DECREF(pValue); if (pValue != NULL) { Py_DECREF(pValue); }
if (pTraceback != NULL) Py_DECREF(pTraceback); if (pTraceback != NULL) { Py_DECREF(pTraceback); }
PyErr_Clear(); PyErr_Clear();

View File

@ -138,67 +138,14 @@ void XMLSerializer::fill_doc(xmlDocPtr doc, const History& hist)
* Creates a DTD declaration. Isn't mandatory. * Creates a DTD declaration. Isn't mandatory.
*/ */
xmlDtdPtr dtd = xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", NULL, (const xmlChar *) "sgpem.dtd"); xmlDtdPtr dtd = xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", NULL, (const xmlChar *) "sgpem.dtd");
//TODO: check for DTD compliance??
XMLVisitor xvisit(root_node); XMLVisitor xvisit(root_node);
xvisit.from_history(hist); xvisit.from_history(hist);
/*
//
// xmlNewChild() creates a new node, which is "attached" as child node
// of root_node node.
//
xmlNodePtr resources_node = xmlNewChild(root_node, NULL, (const xmlChar *) "resources", NULL);
//
// The same as above, but the new child node doesn't have a content
//
xmlNodePtr schedulables_node = xmlNewChild(root_node, NULL, (const xmlChar *) "schedulables", NULL);
fill_resources(resources_node, hist);
fill_schedulables(schedulables_node, hist);
*/
} }
/*
void XMLSerializer::fill_resources(xmlNodePtr resources_node, const History& hist)
{
const Environment& env = hist.get_last_environment();
const Environment::Resources& rvect = env.get_resources();
typedef Environment::Resources::const_iterator res_iterator;
res_iterator iter = rvect.begin();
res_iterator end = rvect.end();
while(iter!=end)
{
XMLVisitor xvisit(resources_node);
Glib::ustring key;
int_to_string((int)(*iter).first, key);
xvisit.from_resource(*((*iter).second), key);
iter++;
}
}
void XMLSerializer::fill_schedulables(xmlNodePtr schedulables_node, const History& hist)
{
const Environment& env = hist.get_last_environment();
const Environment::Processes& pvect = env.get_processes();
typedef std::vector<Process*>::const_iterator proc_iterator;
proc_iterator iter = pvect.begin();
proc_iterator end = pvect.end();
while(iter!=end)
{
XMLVisitor xvisit(schedulables_node);
xvisit.from_process(*(*iter));
iter++;
}
}
*/
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError) void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError)
{ {
/* /*

View File

@ -86,7 +86,7 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
int arrival_time = 0; int arrival_time = 0;
int how_many = 1; int how_many = 1;
bool preemptable = false; bool preemptable = false;
int old_key; int old_key = 0;
Parameters::iterator pos; Parameters::iterator pos;
// read "name" property // read "name" property

View File

@ -44,7 +44,7 @@ XMLVisitor::~XMLVisitor()
{ {
} }
void XMLVisitor::from_resource(const Resource& obj) throw(SerializerError) void XMLVisitor::from_resource(const Resource& /*obj*/) throw(SerializerError)
{ {
throw SerializerError( throw SerializerError(
_("XMLVisitor: unsupported method from_resource(const Resource& obj)") _("XMLVisitor: unsupported method from_resource(const Resource& obj)")
@ -203,8 +203,7 @@ void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(Seria
while (iter != end) while (iter != end)
{ {
const Thread* t = *iter; const Thread* t = *iter;
from_thread(threads_node, *t);
from_thread(threads_node, *(*iter));
iter++; iter++;
} }
} }
@ -244,8 +243,7 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
while (iter != end) while (iter != end)
{ {
const Request* r = *iter; const Request* r = *iter;
from_request(requests_node, *r);
from_request(requests_node, *(*iter));
iter++; iter++;
} }
} }
@ -278,7 +276,7 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
while (iter != end) while (iter != end)
{ {
const SubRequest* sr = *iter; const SubRequest* sr = *iter;
from_subrequest(request_node, *(*iter)); from_subrequest(request_node, *sr);
iter++; iter++;
} }
} }

View File

@ -307,9 +307,9 @@ ConcreteHistory::clear()
ConcreteHistory::ResourcePair ConcreteHistory::ResourcePair
ConcreteHistory::add_resource(const Glib::ustring& name, ConcreteHistory::add_resource(const Glib::ustring& name,
bool preemptable, bool /*preemptable*/,
size_t places, size_t places,
size_t availability) size_t /*availability*/)
{ {
typedef ConcreteEnvironment::Resources Resources; typedef ConcreteEnvironment::Resources Resources;
typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue; typedef ConcreteEnvironment::SubRequestQueue SubRequestQueue;
@ -341,9 +341,9 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
void void
ConcreteHistory::edit_resource(Resource& resource, ConcreteHistory::edit_resource(Resource& resource,
const Glib::ustring& name, const Glib::ustring& name,
bool preemptable, bool /*preemptable*/,
size_t places, size_t places,
size_t availability) size_t /*availability*/)
{ {
// And preemptable and availability?? FIXME! // And preemptable and availability?? FIXME!

View File

@ -37,7 +37,7 @@ namespace sgpem
This class is a direct subclass of the abstract class ProcessStatistics. This class is a direct subclass of the abstract class ProcessStatistics.
For the documentation af all methods refere to it. For the documentation af all methods refere to it.
*/ */
class ConcreteProcessStatistics : public ProcessStatistics class SG_DLLLOCAL ConcreteProcessStatistics : public ProcessStatistics
{ {
public: public:
friend class ConcreteStatistics; friend class ConcreteStatistics;

View File

@ -167,11 +167,13 @@ ConcreteSimulation::step()
{ {
// step forward // step forward
bool yet_to_finish = true; bool yet_to_finish = true;
if (_history.get_front() == _history.get_size() - 1) if (_history.get_front() == _history.get_size() - 1)
if(!_history.is_sealed()) {
yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy(), *get_resource_policy()); if(!_history.is_sealed())
else yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy(), *get_resource_policy());
yet_to_finish = false; else
yet_to_finish = false;
}
if (!yet_to_finish) _history.seal(); if (!yet_to_finish) _history.seal();

View File

@ -22,7 +22,6 @@
#define CONCRETE_SIMULATION_HH 1 #define CONCRETE_SIMULATION_HH 1
#include <sgpemv2/simulation.hh> #include <sgpemv2/simulation.hh>
#include "concrete_history.hh" #include "concrete_history.hh"
@ -35,7 +34,7 @@ namespace sgpem
{ {
class ConcreteSimulation; class ConcreteSimulation;
class ConcreteSimulation : public Simulation class SG_DLLLOCAL ConcreteSimulation : public Simulation
{ {
public: public:
ConcreteSimulation(); ConcreteSimulation();

View File

@ -36,7 +36,7 @@ namespace sgpem
This class is a direct subclass of the abstract class SimulationStatistics. This class is a direct subclass of the abstract class SimulationStatistics.
For the documentation af all methods refere to it. For the documentation af all methods refere to it.
*/ */
class ConcreteSimulationStatistics : public SimulationStatistics class SG_DLLLOCAL ConcreteSimulationStatistics : public SimulationStatistics
{ {
public: public:
friend class ConcreteStatistics; friend class ConcreteStatistics;

View File

@ -38,7 +38,7 @@ namespace sgpem
This class is a direct subclass of the abstract class Statistics. This class is a direct subclass of the abstract class Statistics.
For the documentation af all methods refere to it. For the documentation af all methods refere to it.
*/ */
class ConcreteStatistics : public Statistics class SG_DLLLOCAL ConcreteStatistics : public Statistics
{ {
public: public:
ConcreteStatistics(); ConcreteStatistics();

View File

@ -38,7 +38,7 @@ namespace sgpem
This class is a direct subclass of the abstract class ThreadStatistics. This class is a direct subclass of the abstract class ThreadStatistics.
For the documentation af all methods refere to it. For the documentation af all methods refere to it.
*/ */
class ConcreteThreadStatistics : public ThreadStatistics class SG_DLLLOCAL ConcreteThreadStatistics : public ThreadStatistics
{ {
public: public:
friend class ConcreteProcessStatistics; friend class ConcreteProcessStatistics;

View File

@ -37,7 +37,7 @@ namespace sgpem
/** /**
ResourcePolicyManager is the Abstract Factory for \ref ResourcePolicy objects. ResourcePolicyManager is the Abstract Factory for \ref ResourcePolicy objects.
*/ */
class CppResourcePolicyManager : public ResourcePolicyManager class SG_DLLLOCAL CppResourcePolicyManager : public ResourcePolicyManager
{ {
public: public:
/** \brief CppResourcePolicyManager constructor /** \brief CppResourcePolicyManager constructor

View File

@ -41,7 +41,7 @@ using std::runtime_error;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<CPUPoliciesGatekeeper>; template class Singleton<CPUPoliciesGatekeeper>;
typedef vector<CPUPolicyManager*>::iterator ManagerIterator; typedef vector<CPUPolicyManager*>::iterator ManagerIterator;
typedef map<History*, CPUPolicy*>::iterator ActiveIterator; typedef map<History*, CPUPolicy*>::iterator ActiveIterator;

View File

@ -40,7 +40,7 @@
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<GlobalPreferences>; template class Singleton<GlobalPreferences>;
GlobalPreferences::GlobalPreferences() GlobalPreferences::GlobalPreferences()
: _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000) : _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000)

View File

@ -1,4 +1,4 @@
// src/backend/key_file.hh - Copyright 2005, 2006, University // src/backend/global_preferences_serializer.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied // of Padova, dept. of Pure and Applied
// Mathematics // Mathematics
// //
@ -36,7 +36,7 @@ namespace sgpem
* in the form of: key=value rows. * in the form of: key=value rows.
* *
*/ */
class SG_DLLEXPORT GlobalPreferencesSerializer : public KeyFile class SG_DLLLOCAL GlobalPreferencesSerializer : public KeyFile
{ {
public: public:

View File

@ -35,7 +35,7 @@
using namespace sgpem; using namespace sgpem;
template class SG_DLLEXPORT Singleton<PluginManager>; template class Singleton<PluginManager>;
std::vector<Module*> std::vector<Module*>

View File

@ -40,7 +40,7 @@ using std::runtime_error;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<ResourcePoliciesGatekeeper>; template class Singleton<ResourcePoliciesGatekeeper>;
typedef vector<ResourcePolicyManager*>::iterator ManagerIterator; typedef vector<ResourcePolicyManager*>::iterator ManagerIterator;
typedef map<History*, ResourcePolicy*>::iterator PolicyIterator; typedef map<History*, ResourcePolicy*>::iterator PolicyIterator;

View File

@ -35,7 +35,7 @@ ResourcePolicyFiFo::configure()
} }
void void
ResourcePolicyFiFo::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) ResourcePolicyFiFo::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException) throw(UserInterruptException)
{ {
typedef Environment::SubRequestQueue SubRequestQueue; typedef Environment::SubRequestQueue SubRequestQueue;

View File

@ -36,7 +36,7 @@ namespace sgpem
It's a Strategy wich stay for a resource allocating algorithm. It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy. It implements the related resource allocation policy.
*/ */
class ResourcePolicyFiFo : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyFiFo : public ResourcePolicy
{ {
public: public:
virtual ~ResourcePolicyFiFo(); virtual ~ResourcePolicyFiFo();

View File

@ -34,7 +34,7 @@ ResourcePolicyLiFo::configure()
} }
void void
ResourcePolicyLiFo::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) ResourcePolicyLiFo::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException) throw(UserInterruptException)
{ {
typedef Environment::SubRequestQueue SubRequestQueue; typedef Environment::SubRequestQueue SubRequestQueue;

View File

@ -37,7 +37,7 @@ namespace sgpem
It's a Strategy wich stay for a resource allocating algorithm. It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy. It implements the related resource allocation policy.
*/ */
class ResourcePolicyLiFo : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyLiFo : public ResourcePolicy
{ {
public: public:
virtual ~ResourcePolicyLiFo(); virtual ~ResourcePolicyLiFo();

View File

@ -36,7 +36,7 @@ ResourcePolicyPriority::configure()
} }
void void
ResourcePolicyPriority::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) ResourcePolicyPriority::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException) throw(UserInterruptException)
{ {
typedef Environment::SubRequestQueue SubRequestQueue; typedef Environment::SubRequestQueue SubRequestQueue;

View File

@ -40,7 +40,7 @@ namespace sgpem
/// following the priority of the owners of the requests. /// following the priority of the owners of the requests.
class ResourcePolicyPriority; class ResourcePolicyPriority;
class ResourcePolicyPriority : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyPriority : public ResourcePolicy
{ {
public: public:

View File

@ -35,7 +35,7 @@ ResourcePolicyPriorityInheritance::configure()
} }
void void
ResourcePolicyPriorityInheritance::enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) ResourcePolicyPriorityInheritance::enforce(Environment& /*environment*/, Environment::SubRequestQueue& queue, SubRequest& sr)
throw(UserInterruptException) throw(UserInterruptException)
{ {
typedef Environment::SubRequestQueue SubRequestQueue; typedef Environment::SubRequestQueue SubRequestQueue;

View File

@ -34,7 +34,7 @@ namespace sgpem
* \brief It's a Strategy wich stay for a resource allocating algorithm. * \brief It's a Strategy wich stay for a resource allocating algorithm.
* It implements the related resource allocation policy. * It implements the related resource allocation policy.
*/ */
class ResourcePolicyPriorityInheritance : public ResourcePolicy class SG_DLLLOCAL ResourcePolicyPriorityInheritance : public ResourcePolicy
{ {
public: public:

View File

@ -49,7 +49,7 @@ using namespace std;
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<Scheduler>; template class Singleton<Scheduler>;
typedef std::vector<DynamicProcess*> Processes; typedef std::vector<DynamicProcess*> Processes;
@ -69,8 +69,6 @@ static void terminate_all_requests_of(DynamicThread& thread, ConcreteEnvironment
static void update_allocated_requests(DynamicThread& running_thread, ConcreteEnvironment& environment); static void update_allocated_requests(DynamicThread& running_thread, ConcreteEnvironment& environment);
static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment, ResourcePolicy& resource_policy); static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment, ResourcePolicy& resource_policy);
static void look_for_mutant_request_states(ConcreteEnvironment& environment, unsigned int& alive_threads); static void look_for_mutant_request_states(ConcreteEnvironment& environment, unsigned int& alive_threads);
static void determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr,
const Resource& res, SubRequestQueue& queue);
static void determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queue); static void determine_subr_allocable_status(const Resource& res, const SubRequestQueue& queue);
@ -268,69 +266,6 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
} }
// The following loop determines how many places in the resource are
// really available for a thread, and how many places for a specific
// resource a thread really needs. Admittedly, it's a bit of a hack (in
// the way it's written, not conceptually!)
void
determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr,
const Resource& res, SubRequestQueue& queue)
{
unsigned int total_places = res.get_places();
unsigned int free_places = total_places;
unsigned int needed_places = 0;
unsigned int position_in_queue = 0;
bool too_far_in_the_queue = false;
const SubRequestQueue& const_queue = queue;
for(Iseq<SubRequestQueue::const_iterator> queue_it = iseq(const_queue);
queue_it && free_places >= needed_places; queue_it++, position_in_queue++)
{
SubRequest& sr = **queue_it;
if(sr.get_state() == Request::state_allocated)
{
assert(free_places > 0); // Just to be sure...
free_places--;
}
// Okay, this won't win a beauty contest...
if(&sr.get_request() == &req)
needed_places++;
// Well, and what about this, then?
if(&sr == &subr && position_in_queue + 1 > total_places)
too_far_in_the_queue = true;
} //~ for(over subrequest queue)
// If the number of places this thread need for a resource are
// less or equal the places left free, it's allocable.
if(needed_places <= free_places && !too_far_in_the_queue)
subr.set_state(Request::state_allocable);
else
{
subr.set_state(Request::state_unallocable);
/*
// Okay, this is difficult to understand, so read carefully:
// when we make a subrequest unallocable, it means that the
// whole request is unallocable. However, it may happen that
// there are other subrequests just marked allocable for
// a given resource. Since a request is atomic, either we're
// given *all* the places we asked for in a resource, or none.
// This doesn't affect the state for other subrequests on other
// resources, which may stay (atomically) allocable.
// (Maybe it was better to implement the number of "places"
// needed directly into subrequests, after all...)
for(Iseq<SubRequestQueue::iterator> queue_it = iseq(queue); queue_it; queue_it++)
{
DynamicSubRequest& x = static_cast<DynamicSubRequest&>(**queue_it);
if(&x.get_request() == &req && x.get_state() == Request::state_allocable)
x.set_state(Request::state_unallocable);
}
*/
}
}
// The following loop updates the states of the subrequests depending // The following loop updates the states of the subrequests depending
// on their position in the queue // on their position in the queue
void void

View File

@ -24,6 +24,7 @@
#include <sgpemv2/sgpemv2-visibility.hh> #include <sgpemv2/sgpemv2-visibility.hh>
#include <map> #include <map>
#include <string>
#include <stdexcept> #include <stdexcept>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
@ -34,7 +35,7 @@ namespace sgpem
class SG_DLLEXPORT PolicyParametersException : public std::runtime_error class SG_DLLEXPORT PolicyParametersException : public std::runtime_error
{ {
public: public:
PolicyParametersException(char* msg): std::runtime_error(msg) {} PolicyParametersException(std::string msg): std::runtime_error(msg) {}
}; };

View File

@ -33,7 +33,7 @@
using namespace sgpem; using namespace sgpem;
// Explicit template instantiation to allow to export symbols from the DSO. // Explicit template instantiation to allow to export symbols from the DSO.
template class SG_DLLEXPORT Singleton<ConcreteSimulation>; template class Singleton<ConcreteSimulation>;
Simulation::Simulation() Simulation::Simulation()
: _notify(true) : _notify(true)

View File

@ -38,7 +38,7 @@ namespace sgpem
It IS a Schedulable object. It IS a Schedulable object.
*/ */
class StaticProcess : public StaticSchedulable class SG_DLLLOCAL StaticProcess : public StaticSchedulable
{ {
public: public:
/** \brief Creates a new object with the given parameters. */ /** \brief Creates a new object with the given parameters. */

View File

@ -31,7 +31,7 @@ namespace sgpem
class StaticRequest; class StaticRequest;
class SerializeVisitor; class SerializeVisitor;
class StaticRequest class SG_DLLLOCAL StaticRequest
{ {
public: public:
StaticRequest(StaticThread* thread, unsigned int instant); StaticRequest(StaticThread* thread, unsigned int instant);

View File

@ -21,6 +21,7 @@
#ifndef STATIC_RESOURCE_HH #ifndef STATIC_RESOURCE_HH
#define STATIC_RESOURCE_HH 1 #define STATIC_RESOURCE_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
@ -39,7 +40,7 @@ namespace sgpem
/// copy constructor private. This makes clear that if you want to edit a /// copy constructor private. This makes clear that if you want to edit a
/// static entity, you should reset the ::History, remove the old static /// static entity, you should reset the ::History, remove the old static
/// entity, and create a new dynamic entity for the new static one. /// entity, and create a new dynamic entity for the new static one.
class StaticResource class SG_DLLLOCAL StaticResource
{ {
public: public:
/// \brief Constructor taking a defined name and a number of places. /// \brief Constructor taking a defined name and a number of places.

View File

@ -21,6 +21,7 @@
#ifndef STATIC_SCHEDULABLE_HH #ifndef STATIC_SCHEDULABLE_HH
#define STATIC_SCHEDULABLE_HH 1 #define STATIC_SCHEDULABLE_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
@ -38,7 +39,7 @@ namespace sgpem
* *
* \see DynamicSchedulable * \see DynamicSchedulable
*/ */
class StaticSchedulable class SG_DLLLOCAL StaticSchedulable
{ {
public: public:
/** \brief Create a new object with the given parameters */ /** \brief Create a new object with the given parameters */

View File

@ -45,7 +45,7 @@ namespace sgpem
class StaticRequest; class StaticRequest;
class StaticResource; class StaticResource;
class StaticSubRequest class SG_DLLLOCAL StaticSubRequest
{ {
public: public:
typedef SubRequest::resource_key_t resource_key_t; typedef SubRequest::resource_key_t resource_key_t;

View File

@ -65,7 +65,7 @@ namespace sgpem
/// at which its creation in the operating system is simulated. /// at which its creation in the operating system is simulated.
class StaticThread; class StaticThread;
class StaticThread : public StaticSchedulable class SG_DLLLOCAL StaticThread : public StaticSchedulable
{ {
public: public:

View File

@ -25,7 +25,7 @@
#include <gdkmm/window.h> #include <gdkmm/window.h>
#include <cstring>
#include <cassert> #include <cassert>
#include <memory> #include <memory>
@ -110,8 +110,10 @@ CairoWidget::on_realize()
set_window(window); set_window(window);
window->set_user_data(gobj()); window->set_user_data(gobj());
gtk_style_attach(get_style()->gobj(), window->gobj());
get_style()->set_background(window, Gtk::STATE_ACTIVE); Glib::RefPtr<Gtk::Style> style = get_style ();
style = style->attach (window);
style->set_background(window, Gtk::STATE_ACTIVE);
} }
/* /*

View File

@ -25,6 +25,7 @@
#include <glibmm/ustring.h> #include <glibmm/ustring.h>
#include <cstdlib>
#include <iostream> #include <iostream>
int int

View File

@ -45,6 +45,7 @@
#include <glibmm/timer.h> #include <glibmm/timer.h>
#include <cassert> #include <cassert>
#include <cstdlib>
#include <ios> #include <ios>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>