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
4746ad6d
authored
May 28, 2015
by
Maxime Chéramy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Processor: merge preempt and migrate events
Also add some comments.
parent
6a71b5bc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
24 deletions
+11
-24
simso/core/Processor.py
+11
-24
No files found.
simso/core/Processor.py
View file @
4746ad6d
...
@@ -10,9 +10,8 @@ RESCHED = 1
...
@@ -10,9 +10,8 @@ RESCHED = 1
ACTIVATE
=
2
ACTIVATE
=
2
TERMINATE
=
3
TERMINATE
=
3
TIMER
=
4
TIMER
=
4
MIGRATE
=
5
PREEMPT
=
5
PREEMPT
=
6
SPEED
=
6
SPEED
=
7
class
ProcInfo
(
object
):
class
ProcInfo
(
object
):
...
@@ -80,10 +79,6 @@ class Processor(Process):
...
@@ -80,10 +79,6 @@ class Processor(Process):
"""
"""
self
.
_evts
.
append
((
RESCHED
,))
self
.
_evts
.
append
((
RESCHED
,))
def
migrate
(
self
,
job
):
self
.
_evts
.
append
((
MIGRATE
,
job
))
self
.
_running
=
job
def
activate
(
self
,
job
):
def
activate
(
self
,
job
):
self
.
_evts
.
append
((
ACTIVATE
,
job
))
self
.
_evts
.
append
((
ACTIVATE
,
job
))
...
@@ -91,9 +86,10 @@ class Processor(Process):
...
@@ -91,9 +86,10 @@ class Processor(Process):
self
.
_evts
.
append
((
TERMINATE
,
job
))
self
.
_evts
.
append
((
TERMINATE
,
job
))
self
.
_running
=
None
self
.
_running
=
None
def
preempt
(
self
):
def
preempt
(
self
,
job
=
None
):
self
.
_evts
=
deque
([
e
for
e
in
self
.
_evts
if
e
[
0
]
!=
PREEMPT
])
self
.
_evts
.
append
((
PREEMPT
,))
self
.
_evts
.
append
((
PREEMPT
,))
self
.
_running
=
None
self
.
_running
=
job
def
timer
(
self
,
timer
):
def
timer
(
self
,
timer
):
self
.
_evts
.
append
((
TIMER
,
timer
))
self
.
_evts
.
append
((
TIMER
,
timer
))
...
@@ -196,8 +192,6 @@ class Processor(Process):
...
@@ -196,8 +192,6 @@ class Processor(Process):
print
(
self
.
sim
.
now
(),
"hold"
,
evt
[
1
]
.
overhead
)
print
(
self
.
sim
.
now
(),
"hold"
,
evt
[
1
]
.
overhead
)
yield
hold
,
self
,
evt
[
1
]
.
overhead
yield
hold
,
self
,
evt
[
1
]
.
overhead
evt
[
1
]
.
call_handler
()
evt
[
1
]
.
call_handler
()
elif
evt
[
0
]
==
MIGRATE
:
self
.
monitor
.
observe
(
ProcOverheadEvent
(
"Migration"
))
elif
evt
[
0
]
==
SPEED
:
elif
evt
[
0
]
==
SPEED
:
self
.
_speed
=
evt
[
1
]
self
.
_speed
=
evt
[
1
]
elif
evt
[
0
]
==
RESCHED
:
elif
evt
[
0
]
==
RESCHED
:
...
@@ -208,16 +202,14 @@ class Processor(Process):
...
@@ -208,16 +202,14 @@ class Processor(Process):
yield
hold
,
self
,
self
.
sched
.
overhead
# overhead scheduling
yield
hold
,
self
,
self
.
sched
.
overhead
# overhead scheduling
if
type
(
decisions
)
is
not
list
:
if
type
(
decisions
)
is
not
list
:
decisions
=
[
decisions
]
decisions
=
[
decisions
]
decisions
=
[
d
for
d
in
decisions
if
d
is
not
None
]
for
decision
in
decisions
:
for
job
,
cpu
in
decisions
:
if
decision
is
None
:
# If there is nothing to change, simply ignore:
continue
else
:
job
,
cpu
=
decision
if
cpu
.
running
==
job
:
if
cpu
.
running
==
job
:
continue
continue
# If trying to execute a terminated job, warn and ignore:
if
job
is
not
None
and
not
job
.
is_active
():
if
job
is
not
None
and
not
job
.
is_active
():
print
(
"Can't schedule a terminated job! ({})"
print
(
"Can't schedule a terminated job! ({})"
.
format
(
job
.
name
))
.
format
(
job
.
name
))
...
@@ -225,23 +217,18 @@ class Processor(Process):
...
@@ -225,23 +217,18 @@ class Processor(Process):
# if the job was running somewhere else, stop it.
# if the job was running somewhere else, stop it.
if
job
and
job
.
cpu
.
running
==
job
:
if
job
and
job
.
cpu
.
running
==
job
:
job
.
cpu
.
evts
=
[
e
for
e
in
self
.
_evts
if
e
[
0
]
!=
MIGRATE
]
job
.
cpu
.
preempt
()
job
.
cpu
.
preempt
()
# Send that job to processor cpu.
# Send that job to processor cpu.
if
job
is
None
:
cpu
.
preempt
(
job
)
cpu
.
preempt
()
else
:
cpu
.
migrate
(
job
)
if
job
:
if
job
:
job
.
task
.
cpu
=
cpu
job
.
task
.
cpu
=
cpu
# Forbid to run a job simultaneously on 2 or more processors.
running_tasks
=
[
running_tasks
=
[
cpu
.
running
.
name
cpu
.
running
.
name
for
cpu
in
self
.
_model
.
processors
if
cpu
.
running
]
for
cpu
in
self
.
_model
.
processors
if
cpu
.
running
]
#if len(set(running_tasks)) != len(running_tasks):
# print(running_tasks)
assert
len
(
set
(
running_tasks
))
==
len
(
running_tasks
),
\
assert
len
(
set
(
running_tasks
))
==
len
(
running_tasks
),
\
"Try to run a job on 2 processors simultaneously!"
"Try to run a job on 2 processors simultaneously!"
...
...
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