Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
simso
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ac6a96ae
authored
Jan 31, 2018
by
fshahinfar1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement LSTR algorithm
parent
2b1ec786
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
2 deletions
+51
-2
simso/schedulers/LSTR.py
+51
-2
No files found.
simso/schedulers/LSTR.py
View file @
ac6a96ae
...
@@ -9,4 +9,54 @@ class LSTR(Scheduler):
...
@@ -9,4 +9,54 @@ class LSTR(Scheduler):
"""
"""
def
init
(
self
):
def
init
(
self
):
pass
self
.
ready_list
=
[]
\ No newline at end of file
self
.
timer
=
Timer
(
self
.
sim
,
LSTR
.
virtual_event
,
(
self
,
self
.
processors
[
0
]),
1
,
one_shot
=
False
)
self
.
timer
.
start
()
def
virtual_event
(
self
,
cpu
):
self
.
reschedule
(
cpu
)
def
reschedule
(
self
,
cpu
):
if
self
.
ready_list
:
cpu
.
resched
()
def
LSTR_rank
(
self
,
job
):
"""
calculates rank described in LSTR algorithm for given job
return value should be non-negative, negative value means that job has passed deadline
"""
if
not
job
:
return
0
# print(job.absolute_deadline, job.deadline)
din
=
job
.
absolute_deadline
-
self
.
sim
.
now_ms
()
if
din
==
0
:
return
0
return
job
.
ret
/
din
def
on_activate
(
self
,
job
):
self
.
ready_list
.
append
(
job
)
self
.
reschedule
(
job
.
cpu
)
def
on_terminated
(
self
,
job
):
self
.
ready_list
.
remove
(
job
)
self
.
reschedule
(
job
.
cpu
)
def
schedule
(
self
,
cpu
):
decision
=
[]
if
self
.
ready_list
:
self
.
ready_list
.
sort
(
key
=
self
.
LSTR_rank
,
reverse
=
True
)
number_of_processors
=
len
(
self
.
processors
)
jobs
=
self
.
ready_list
[:
number_of_processors
]
available_proc
=
[
p
for
p
in
self
.
processors
if
p
.
running
not
in
jobs
]
for
job
in
jobs
:
if
job
.
is_running
():
continue
for
cpu
in
available_proc
:
job_on_cpu_rank
=
self
.
LSTR_rank
(
cpu
.
running
)
if
job_on_cpu_rank
<
self
.
LSTR_rank
(
job
):
decision
.
append
((
job
,
cpu
))
available_proc
.
remove
(
cpu
)
break
return
decision
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment