- Catch UserInterruptException launched from
PythonPolicy in Scheduler, but it cheerfully segfaults python... git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@464 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
8c39173c2f
commit
0a6b34d6ab
|
@ -161,7 +161,8 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
||||||
// we shot it stone dead! Bang.
|
// we shot it stone dead! Bang.
|
||||||
|
|
||||||
bool still_locked;
|
bool still_locked;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
Py_UNBLOCK_THREADS;
|
Py_UNBLOCK_THREADS;
|
||||||
usleep(25000); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
usleep(25000); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
||||||
Py_BLOCK_THREADS;
|
Py_BLOCK_THREADS;
|
||||||
|
@ -171,9 +172,12 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
||||||
Py_DECREF(retval);
|
Py_DECREF(retval);
|
||||||
|
|
||||||
if(i++ > 120)
|
if(i++ > 120)
|
||||||
|
{
|
||||||
throw UserInterruptException("User-defined policy is "
|
throw UserInterruptException("User-defined policy is "
|
||||||
"taking too long to terminate.");
|
"taking too long to terminate.");
|
||||||
} while(still_locked);
|
}
|
||||||
|
}
|
||||||
|
while(still_locked);
|
||||||
|
|
||||||
|
|
||||||
// What we should really do here:
|
// What we should really do here:
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#include "policy.hh"
|
#include "policy.hh"
|
||||||
#include "scheduler.hh"
|
#include "scheduler.hh"
|
||||||
#include "policy_manager.hh"
|
#include "policy_manager.hh"
|
||||||
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace memory;
|
using namespace memory;
|
||||||
|
@ -78,6 +81,8 @@ Scheduler::get_policy()
|
||||||
|
|
||||||
void
|
void
|
||||||
Scheduler::step_forward()
|
Scheduler::step_forward()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Policy& policy = get_policy();
|
Policy& policy = get_policy();
|
||||||
|
|
||||||
|
@ -189,3 +194,19 @@ Scheduler::step_forward()
|
||||||
*/
|
*/
|
||||||
h.enqueue_slice(_ready_queue);
|
h.enqueue_slice(_ready_queue);
|
||||||
}
|
}
|
||||||
|
catch( UserInterruptException e )
|
||||||
|
{
|
||||||
|
// FIXME : Naive.
|
||||||
|
cerr << "Exception: " << e.what() << endl;
|
||||||
|
|
||||||
|
// Errrrr.... you won't like this:
|
||||||
|
_policy_manager.init();
|
||||||
|
// https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1165761&group_id=5470
|
||||||
|
// maybe it's that??? oh, damn.
|
||||||
|
// or maybe not. see http://www.python.org/doc/2.4.2/api/initialization.html
|
||||||
|
|
||||||
|
// Tell:
|
||||||
|
// - the user that the policy sucks
|
||||||
|
// - SimulationController that everything stopped
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ class fcfs(Policy) :
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def sort_queue(self, event, queue):
|
def sort_queue(self, event, queue):
|
||||||
|
#while True:
|
||||||
|
# pass
|
||||||
cmpf = lambda a, b: \
|
cmpf = lambda a, b: \
|
||||||
a.get_schedulable().get_arrival_time() < \
|
a.get_schedulable().get_arrival_time() < \
|
||||||
b.get_schedulable().get_arrival_time()
|
b.get_schedulable().get_arrival_time()
|
||||||
|
|
Loading…
Reference in New Issue