sgpemv2/src/builtin-policies/fcfs.py

34 lines
937 B
Python
Raw Normal View History

from Policy import Policy
class fcfs(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):
print 'Entering sort_queue'
print queue.size()
print dir(queue.get_item_at(0))
for i in range(0, queue.size()):
ss = queue.get_item_at(i)
print ss.get_schedulable().get_name()
cmpf = lambda a, b: \
a.get_schedulable().get_arrival_time() < \
b.get_schedulable().get_arrival_time()
try:
self.sort(queue,cmpf)
except:
print "Unexpected error:", sys.exc_info()[0]
raise
for i in range(0, queue.size()):
ss = queue.get_item_at(i)
print ss.get_schedulable().get_name()