Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
taskscheduler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Schulcz Ferenc
taskscheduler
Commits
08617608
Commit
08617608
authored
7 years ago
by
sfphoton
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: RR will now always check if swap is needed when the active task ran (another) 2 CPU cycles.
parent
7f607dcb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/RR.java
+13
-5
13 additions, 5 deletions
src/RR.java
with
13 additions
and
5 deletions
src/RR.java
+
13
−
5
View file @
08617608
...
...
@@ -13,7 +13,7 @@ public class RR {
private
boolean
enabled
=
true
;
private
Que
ue
<
Task
>
waitingQueue
=
new
ArrayDeque
<>();
//inactive tasks
private
ArrayDeq
ue
<
Task
>
waitingQueue
=
new
ArrayDeque
<>();
//inactive tasks
private
Task
activeTask
=
null
;
//the active task; null if there are none
public
RR
(
Global
global
)
{
...
...
@@ -27,12 +27,12 @@ public class RR {
public
void
stop
()
{
enabled
=
false
;
runningFor
=
0
;
if
(
activeTask
!=
null
)
waitingQueue
.
add
(
activeTask
);
if
(
activeTask
!=
null
)
waitingQueue
.
add
Last
(
activeTask
);
activeTask
=
null
;
}
public
void
add
(
Task
t
)
{
waitingQueue
.
add
(
t
);
waitingQueue
.
add
Last
(
t
);
}
/**
...
...
@@ -51,14 +51,16 @@ public class RR {
//swapping
if
(
waitingQueue
.
size
()
>
0
&&
(
runningFor
==
timeSlice
||
activeTask
==
null
))
{
//we swap if we can and if we need to; we need to when the running period is over or the current task is not running anymore
if
(
activeTask
!=
null
)
waitingQueue
.
add
(
activeTask
);
activeTask
=
waitingQueue
.
remove
();
if
(
activeTask
!=
null
)
waitingQueue
.
add
Last
(
activeTask
);
activeTask
=
waitingQueue
.
remove
First
();
global
.
changeRunning
(
activeTask
);
runningFor
=
0
;
}
if
(
runningFor
==
timeSlice
)
runningFor
=
0
;
//System.out.println("Running RR: " + ((activeTask == null) ? "null" : activeTask.name));
//registering time flow
...
...
@@ -74,4 +76,10 @@ public class RR {
return
activeTask
==
null
&&
waitingQueue
.
size
()==
0
;
}
private
String
wqs
()
{
String
ret
=
""
;
for
(
Task
t
:
waitingQueue
)
ret
+=
t
.
name
;
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment