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
34b6f852
authored
May 27, 2015
by
Maxime Chéramy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update G-EDF implementation.
parent
a80e5063
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
17 deletions
+9
-17
simso/schedulers/EDF.py
+8
-16
simso/schedulers/EDF2.py
+1
-1
No files found.
simso/schedulers/EDF.py
View file @
34b6f852
...
@@ -7,27 +7,20 @@ from simso.core import Scheduler
...
@@ -7,27 +7,20 @@ from simso.core import Scheduler
class
EDF
(
Scheduler
):
class
EDF
(
Scheduler
):
"""Earliest Deadline First"""
"""Earliest Deadline First"""
def
init
(
self
):
self
.
ready_list
=
[]
def
on_activate
(
self
,
job
):
def
on_activate
(
self
,
job
):
self
.
ready_list
.
append
(
job
)
job
.
cpu
.
resched
()
job
.
cpu
.
resched
()
def
on_terminated
(
self
,
job
):
def
on_terminated
(
self
,
job
):
if
job
in
self
.
ready_list
:
job
.
cpu
.
resched
()
self
.
ready_list
.
remove
(
job
)
else
:
job
.
cpu
.
resched
()
def
schedule
(
self
,
cpu
):
def
schedule
(
self
,
cpu
):
ready_jobs
=
[
j
for
j
in
self
.
ready_list
if
j
.
is_active
()]
# List of ready jobs not currently running:
ready_jobs
=
[
t
.
job
for
t
in
self
.
task_list
if
t
.
is_active
()
and
not
t
.
job
.
is_running
()]
if
ready_jobs
:
if
ready_jobs
:
# Key explanations:
# Select a free processor or, if none,
# First the free processors
# the one with the greatest deadline (self in case of equality):
# Among the others, get the one with the greatest deadline
# If equal, take the one used to schedule
key
=
lambda
x
:
(
key
=
lambda
x
:
(
1
if
not
x
.
running
else
0
,
1
if
not
x
.
running
else
0
,
x
.
running
.
absolute_deadline
if
x
.
running
else
0
,
x
.
running
.
absolute_deadline
if
x
.
running
else
0
,
...
@@ -35,11 +28,10 @@ class EDF(Scheduler):
...
@@ -35,11 +28,10 @@ class EDF(Scheduler):
)
)
cpu_min
=
max
(
self
.
processors
,
key
=
key
)
cpu_min
=
max
(
self
.
processors
,
key
=
key
)
# Select the job with the least priority:
job
=
min
(
ready_jobs
,
key
=
lambda
x
:
x
.
absolute_deadline
)
job
=
min
(
ready_jobs
,
key
=
lambda
x
:
x
.
absolute_deadline
)
if
(
cpu_min
.
running
is
None
or
if
(
cpu_min
.
running
is
None
or
cpu_min
.
running
.
absolute_deadline
>
job
.
absolute_deadline
):
cpu_min
.
running
.
absolute_deadline
>
job
.
absolute_deadline
):
self
.
ready_list
.
remove
(
job
)
print
(
self
.
sim
.
now
(),
job
.
name
,
cpu_min
.
name
)
if
cpu_min
.
running
:
self
.
ready_list
.
append
(
cpu_min
.
running
)
return
(
job
,
cpu_min
)
return
(
job
,
cpu_min
)
simso/schedulers/EDF2.py
View file @
34b6f852
"""
"""
Implementation of the Global-EDF (Earliest Deadline First) for multiprocessor
Implementation of the Global-EDF (Earliest Deadline First) for multiprocessor
architectures.
architectures
(alternative implementation as the one provided by EDF.py)
.
"""
"""
from
simso.core
import
Scheduler
from
simso.core
import
Scheduler
...
...
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