- Poll more often to make "jump_to()" faster. Also increase
time given to a policy before judging it dead to ~5 seconds. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1076 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
c6612d4ad4
commit
eec74de632
|
@ -18,6 +18,8 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "python_cpu_policy.hh"
|
||||
|
||||
#include <limits>
|
||||
|
@ -27,9 +29,6 @@
|
|||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
#define WAIT_FOR (250000)
|
||||
|
||||
|
||||
// Static member data
|
||||
Glib::StaticRecMutex PythonCPUPolicy::_mtx = GLIBMM_STATIC_REC_MUTEX_INIT;
|
||||
|
||||
|
@ -225,6 +224,9 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
|
|||
void
|
||||
PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPolicyException)
|
||||
{
|
||||
// Polling time
|
||||
static const int wait_for = 150000;
|
||||
|
||||
PyThreadState* _save;
|
||||
int i = 0; // We give the sort_queue() three seconds max time, then...
|
||||
// we shot it stone dead! Bang.
|
||||
|
@ -233,7 +235,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
do
|
||||
{
|
||||
Py_UNBLOCK_THREADS;
|
||||
usleep(WAIT_FOR); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
||||
usleep(wait_for); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
||||
Py_BLOCK_THREADS;
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "mutex_test_lock", NULL);
|
||||
|
@ -241,7 +243,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
still_locked = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
|
||||
if (i++ > 12) /* waits for WAIT_FOR * 12 microseconds == 3 secs */
|
||||
if (i++ > (1000000 / wait_for) * 5) /* waits for ~5 seconds */
|
||||
{
|
||||
PyThreadState_Clear(_save);
|
||||
// As the API documentation says, the caller of PyEval_RestoreThread
|
||||
|
|
Loading…
Reference in New Issue