Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
38b7b0a5
Commit
38b7b0a5
authored
Mar 03, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OperatorPreemptive sortEntites now gives priority to entities which are critical
parent
5ada219d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
dream/simulation/Operator.py
dream/simulation/Operator.py
+1
-1
dream/simulation/OperatorPreemptive.py
dream/simulation/OperatorPreemptive.py
+11
-3
No files found.
dream/simulation/Operator.py
View file @
38b7b0a5
...
...
@@ -58,7 +58,7 @@ class Operator(Repairman): # XXX isn't it the other way around ?
raise
ValueError
(
"Unknown scheduling rule %s for %s"
%
(
scheduling_rule
,
id
))
# =======================================================================
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# =======================================================================
def
sortEntities
(
self
):
...
...
dream/simulation/OperatorPreemptive.py
View file @
38b7b0a5
...
...
@@ -90,7 +90,7 @@ class OperatorPreemptive(Operator):
#if the Entity to be forwarded to the station currently processed by the operator is critical
if
requestingObjectQueue
[
0
].
isCritical
:
#if the receiver does not hold an Entity that is also critical
if
not
victimQueue
[
0
].
isCritical
and
not
receivingObjectQueue
[
0
].
isCritical
:
if
not
victimQueue
[
0
].
isCritical
and
not
receivingObjectQueue
[
0
].
isCritical
and
victim
.
Up
:
# then the receiver must be preemptied before it can receive any entities from the calerObject
victim
.
shouldPreempt
=
True
victim
.
preempt
()
...
...
@@ -105,9 +105,17 @@ class OperatorPreemptive(Operator):
# checks if the worker is available
# =======================================================================
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
# TODO: to discuss with George about the use of callerObject
activeResource
=
self
.
getResource
()
activeResourceQueue
=
activeResource
.
getResourceQueue
()
len
(
activeResourceQueue
)
<
self
.
capacity
# =======================================================================
# override the default method so that Entities
# that are critical got served first
# =======================================================================
def
sortEntities
(
self
):
Operator
.
sortEntities
(
self
)
#do the default sorting first
activeObjectQ
=
self
.
activeCallersList
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
identifyEntityToGet
().
isCritical
,
reverse
=
True
)
\ No newline at end of file
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