- Add SJF
- Re-enable FCFS sorting function - Correct bug in PythonPolicy that wronged return value of is_pre_emptible() git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@435 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
5dddd9b488
commit
7ce8cf93c3
|
@ -305,7 +305,8 @@ noinst_HEADERS += \
|
|||
|
||||
# built-in policies
|
||||
pyc_PYTHON = \
|
||||
src/builtin-policies/fcfs.py
|
||||
src/builtin-policies/fcfs.py \
|
||||
src/builtin-policies/sjf.py
|
||||
|
||||
# ############################################################
|
||||
#
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "python_policy.hh"
|
||||
#include <limits>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
|
@ -134,7 +135,7 @@ PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
|||
|
||||
// Parse return value stored in global Python object
|
||||
retval = PyDict_GetItemString(_adapter_dict, "_ret_val");
|
||||
return static_cast<bool>(PyInt_AsLong(retval));
|
||||
return PyBool_Check(retval);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,5 +78,6 @@ PythonPolicyManager::init()
|
|||
|
||||
// FIXME : Hardcoded policy name
|
||||
char* policy_name = "fcfs";
|
||||
//char* policy_name = "sjf";
|
||||
_python_policy = std::auto_ptr<PythonPolicy>(new PythonPolicy(policy_name));
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@ class fcfs(Policy) :
|
|||
cmpf = lambda a, b: \
|
||||
a.get_schedulable().get_arrival_time() < \
|
||||
b.get_schedulable().get_arrival_time()
|
||||
#self.sort(queue,cmpf)
|
||||
self.sort(queue,cmpf)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from Policy import Policy
|
||||
import sys
|
||||
|
||||
class sjf(Policy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
def configure(self):
|
||||
print 'No options to configure for fcfs'
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def get_time_slice(self):
|
||||
return -1
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
cmpf = lambda a, b: \
|
||||
a.get_cpu_time_left() < \
|
||||
b.get_cpu_time_left()
|
||||
self.sort(queue,cmpf)
|
Loading…
Reference in New Issue