2006-02-21 08:39:39 +01:00
|
|
|
from Policy import Policy
|
|
|
|
|
2006-02-21 23:57:14 +01:00
|
|
|
class fcfs(Policy) :
|
2006-02-21 08:39:39 +01:00
|
|
|
def __init__(self):
|
|
|
|
pass;
|
|
|
|
|
|
|
|
def configure(self):
|
2006-02-21 23:57:14 +01:00
|
|
|
print 'No options to configure for fcfs'
|
2006-02-21 08:39:39 +01:00
|
|
|
|
|
|
|
def is_preemptive(self):
|
|
|
|
return False
|
|
|
|
|
2006-02-22 16:16:08 +01:00
|
|
|
def get_time_slice(self):
|
|
|
|
return -1
|
2006-02-21 08:39:39 +01:00
|
|
|
|
|
|
|
def sort_queue(self, event, queue):
|
2006-02-23 12:29:25 +01:00
|
|
|
print 'Entering sort_queue'
|
|
|
|
print queue.size()
|
2006-02-23 19:55:14 +01:00
|
|
|
print queue.get_item_at(0)
|
2006-02-23 12:29:25 +01:00
|
|
|
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()
|
2006-02-23 19:55:14 +01:00
|
|
|
# Uncomment this to try the qsort algorithm with FCFS
|
|
|
|
#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
|
|
|
|
|