Skip to content

Commit

Permalink
original slot shifting initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
gokulvasan committed Mar 13, 2016
1 parent f229628 commit c77ff90
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 60 deletions.
10 changes: 7 additions & 3 deletions SlotShifting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from simso.core import Scheduler
from simso.core import Scheduler, Timer

class SlotShifting(Scheduler):

Expand All @@ -11,15 +11,18 @@ def init(self):
self.slot_boundary = 0
self.slot_count = 0
self.slot_timer = Timer(
self.sim, SlotShifting.decision, (self, ), 5,
cpu=self.processors[0], in_ms=True, one_shot=True)
self.sim, SlotShifting.decision, (self, ), 1,
cpu=self.processors[0], in_ms=True, one_shot=False)
self.slot_timer.start()
print " IN SCHEDULER"
self.interval.print_def_interval()

def decision(self, cpu=None):

if cpu is None:
cpu = self.processors[0]
cpu.resched()
print "Timer Activation"
self.slot_boundary = 1

def on_activate(self, job):
Expand All @@ -41,6 +44,7 @@ def schedule(self, cpu):
2. run acceptance and guarantee
3. run EDF on ready_list
"""
print "Schedule"
if self.slot_boundary == 1:
self.slot_boundary = 0
else:
Expand Down
172 changes: 150 additions & 22 deletions interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ def new_intr_append(self, intr_id, start, end, sc):

def new_intr_insert(self, intr_id, start, end, sc, node):
intr_node = interval_node(intr_id, start, end, sc)
self.intr_list.insert(node, intr_node)
list_node = self.intr_list.insert(node, intr_node)
self.intr_count += 1

return list_node

def goto_nxt_interval(self, data_type):
"""
This will move the curr_interval to nxt interval
Expand Down Expand Up @@ -139,9 +140,13 @@ def reset_iterator(self):
Resets the iterator
"""
self.curr_point = None

def set_iterator(self, iter_point):
self.curr_point = iter_point

def get_curr_iterator(self):
return self.curr_point

def set_curr_interval(self, intr):
"""
Sets intr as current interval
Expand All @@ -155,6 +160,31 @@ def get_curr_interval(self):
def get_intr_count(self):
return self.intr_count

def intr_reverse(self):
self.intr_list.reverse()

def intr_list(self):
return self.intr_list

def update_intr(self, time_progressed, task):
"""
Here time progress is in slot, but
I should make this work generically, i.e.
when notion of slot is removed then still it
should work in next level
WHAT SHLD THIS DO:
1. based on time progressed;
progress the current interval
2. update_sc
"""
if time_progressed >= self.curr_interval.end:
curr_intr = self.goto_nxt_interval(None)
if curr_intr == None
return None
self.set_curr_interval(curr_intr)

self.update_sc(task.data)

def update_sc(self, task_data):
"""
Original update_sc
Expand All @@ -166,26 +196,116 @@ def update_sc(self, task_data):
if 2 == task_data.tsk_type: #softAper
break
intr = tmp.get_data()
intr.set_sc(intr.sc()+1)
intr.set_sc(intr.sc + 1)
if intr.id == self.curr_interval.id: #task belongs to same interval
break
if intr.sc >= 0: #task interval is +ve just leave
if intr.sc >= 0: #task intr is +ve just leave
break
tmp = self.intr_list.go_prev(tmp) #else keep iterating backwards
def intr_reverse(self):
self.intr_list.reverse()

def split_intr(self, intr, split_point):
pass
def Aperiodic_test(self, Atask,time_progressed):
curr_iter_point = self.curr_point
ret = None

def Acceptance_test(self, Atask):
pass
wcet_time = Atask.wcet
wcet_slot = wcet_time / quantum_notion
dl_time = Atask.dl
dl_slot = dl_time / quantum_notion

if self.acceptance_test(wcet_slot, dl_slot):
guarantee_task(Atask, wcet_slot, dl_slot, time_progressed)
ret = Atask;

self.set_iterator(curr_iter_point)
return ret

def acceptance_test(self,wcet_slot, dl_slot):

intr = self.curr_interval
sum = 0
while 1:
if intr.end < dl_slot:
break
sum += intr.sc
intr = self.goto_nxt_interval(None)

dl_sc = min(intr.sc, (dl_slot - intr.start) )
sum += max(0, dl_sc)

if sum >= wcet_slot:
return 1
else:
return 0

def split_intr(self, intr_right, split_point, time_progressed):
"""
# here do affilation in aperiodic task.i.e.
# association
"""
new_intr_id = self.intr_count + 1
new_intr_end = split_point

if intr_right == self.get_curr_interval():
new_intr_start = time_progresed
else:
new_intr_start = intr_right.start

new_intr_sc = (split_point - new_intr_start) + 1

intr_right.start = split_point + 1
intr_right.sc = intr.sc - new_intr_sc
new_intr_sc = new_intr_sc - min(0, intr_right.sc)

curr_point = self.get_curr_iterator()
insert_node = self.intr_list.go_prev(curr_point)

intr_left = new_intr_insert(new_intr_id,
new_intr_start,
new_intr_end,
new_intr_sc,
insert_node)
return intr_left

def guarantee_task(self, Atask, wcet_slot, dl_slot, time_progressed):

"""
This goes with the assumption that acceptance
test has already moved curr_iterator to interval
where Atask will fall.
"""
intr_left = None
intr = self.get_curr_iterator()
intr_right = self.intr_list.get_data(intr)
if intr_right.end > dl_slot:
intr_left = self.split_intr(intr_right,
dl_slot, time_progressed)
intr_left_data = self.intr_list.get_data(intr_left)

task_intr_asco = task_intr_association()
task_intr_asco.append_node(1, intr_left, intr_left_data.id)
tsk_data = task_data(tsk_intr_asco, 1, 1)
Atask._task_info.data = tsk_data #This needs better abstraction
self.set_curr_iterator(intr_left)

delta = wcet_slot
if intr_left != None:
Intr_iterator = intr_left_data
else:
intr_iterator = intr_right

while delta:
if intr_iterator.sc > 0:
if intr_iterator.sc >= delta:
intr_iterator.sc = intr_iterator.sc - delta
delta = 0
else
delta = delta - intr_iterator.sc
intr_iterator.sc = -delta
else
intr_iterator.sc += -delta

intr_iterator = goto_prev_interval(None)

def Guarantee_algo(self, Atask):
pass

def intr_list(self):
return self.intr_list
def print_intr_list(self):
i = 0
node = None
Expand Down Expand Up @@ -222,10 +342,9 @@ def update_sc(self, curr_intr, task):
"""
pass

def goto_nxt_interval(self, data_type):
pass
def set_curr_interval(self):
"""
This is where defereed update happens
"""
pass
def print_def_interval(self):
i = 0
Expand All @@ -236,16 +355,25 @@ def print_def_interval(self):
self.__print_intr(data)
i += 1
def __print_intr(self, node):
print "==========="
print "======{}=====".format(node)
print "intr_id{}".format(node.id)
print "start {}".format(node.start)
print "end {}".format(node.end)
print "SC {}".format(node.sc)
print "update_val {}".format(node.update_val)
print "rec_Val {}".format(node.rec_val)
print "lent_till {}".format(node.lent_till)
print "lender {}".format(node.lender)

if node.lent_till != None:
l_till = node.lent_till
data = l_till.get_data()
print "lent_till {}".format(data.id)
else:
print "lent_till {}".format(None)
if node.lender != None:
lender = node.lender
data = lender.get_data()
print "lender {}".format(data.id)
else:
print "lender {}".format(None)
"""
i = interval()
i.new_intr_append(1, 1, 1, 1)
Expand Down
18 changes: 14 additions & 4 deletions list.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,29 @@ def go_prev(self, node):
return node.get_prev()
def get_head(self):
return self.head
"""

i = locallist()
i.append(1)
i.append(2)
i.append(3)
i.append(4)
n = i.go_nxt(None)
print i.get_data(n)
n = i.go_nxt(n)
print i.get_data(n)
i.insert(n,5)
#i.insert(n,5)
#n = i.go_nxt(n)
print i.get_data(n)
n = i.go_nxt(n)
print i.get_data(n)
# print i.get_data(None)
n = i.go_nxt(n)
print i.get_data(n)
"""

# print i.get_data(None)
print "moving prev"
n = i.go_prev(n)
print i.get_data(n)
n = i.go_prev(n)
print i.get_data(n)
n = i.go_prev(n)
print i.get_data(n)
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@ def main():

associate = association(remote)

interval = associate.create_intr_list(associate)
interval = associate.create_def_intr_list(associate)

associate.create_relation_window(associate, interval)

while 1:
j = associate.create_tsk(associate, interval, configuration)
if(j != 0):
break

configuration.duration = 420 * configuration.cycles_per_ms

configuration.add_processor(name="CPU 1", identifier=1)

configuration.scheduler_info.filename = "./SlotShifting.py"

configuration.scheduler_info.data = interval


configuration.check_all()

model = Model(configuration)

model.run_model()


main()
Loading

0 comments on commit c77ff90

Please sign in to comment.