- Fix test to initialize a set of processes and run a simulation

- The test needs to be linked to Gtkmm, even if it doesn't use it. 
This is wrong and a coding anomaly that will need to be resolved.
- Add debug code to fcfs.py. Please remove it when it'll be okay
- Calling dir(SchedulableList.get_item_at(x)) from Python shows
a worringly empty list!


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@395 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-02-23 11:29:25 +00:00
parent a2a492b5d5
commit 8d6b7c500e
11 changed files with 236 additions and 33 deletions

View file

@ -1,4 +1,4 @@
// src/backend/python_policy.cc - Copyright 2005, 2006, University
// src/backend/pyloader/python_policy.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@ -90,22 +90,26 @@ PythonPolicy::~PythonPolicy()
void
PythonPolicy::configure()
PythonPolicy::configure() throw(UserInterruptException)
{
PyObject* retval = PyObject_CallMethod(_adapter, "async_configure", NULL);
Py_DECREF(retval);
wait_unlock();
}
void
PythonPolicy::sort_queue(Scheduler::event event) const
PythonPolicy::sort_queue(Scheduler::event event) const throw(UserInterruptException)
{
PyObject* pEvent = PyInt_FromLong(event);
PyObject* pMethodName = PyString_FromString("async_sort_queue");
PyObject* retval = PyObject_CallMethodObjArgs(_adapter, pMethodName, pEvent, NULL);
// Do minimal debugging
if(!retval) PyErr_Print();
else Py_DECREF(retval);
Py_DECREF(pMethodName);
Py_DECREF(pEvent);
@ -121,7 +125,8 @@ PythonPolicy::get_description() const
bool
PythonPolicy::is_pre_emptive() const {
PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
{
PyObject* retval = PyObject_CallMethod(_adapter, "async_is_preemptive", NULL);
Py_DECREF(retval);
@ -134,7 +139,7 @@ PythonPolicy::is_pre_emptive() const {
int
PythonPolicy::get_time_slice() const {
PythonPolicy::get_time_slice() const throw(UserInterruptException) {
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL);
Py_DECREF(retval);
@ -154,11 +159,21 @@ PythonPolicy::set_time_slice(const int&)
void
PythonPolicy::wait_unlock() const
PythonPolicy::wait_unlock() const throw(UserInterruptException)
{
PyThreadState *_save;
Py_UNBLOCK_THREADS
sleep(2); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS
// Now check if lock has been released, else
// throw an exception
PyObject* retval = PyObject_CallMethod(_lock, "test", NULL);
bool still_locked = static_cast<bool>(PyInt_AsLong(retval));
Py_DECREF(retval);
if(still_locked)
throw UserInterruptException("User-defined policy is taking too long to terminate.");
// What we should really do here:
/* do {
@ -175,5 +190,4 @@ PythonPolicy::wait_unlock() const
all's went okay, can exit loop
} */
Py_BLOCK_THREADS
}