- 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:
tchernobog 2006-02-24 11:17:37 +00:00
parent 5dddd9b488
commit 7ce8cf93c3
5 changed files with 27 additions and 3 deletions

View File

@ -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
# ############################################################
#

View File

@ -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);
}

View File

@ -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));
}

View File

@ -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)

View File

@ -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)