Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nils Vreman
ScheduLearn
Commits
9bc57289
Commit
9bc57289
authored
Feb 11, 2020
by
Nils Vreman
Browse files
Added DMS and fixed RMS
parent
2be60a65
Changes
6
Hide whitespace changes
Inline
Side-by-side
TODO.md
View file @
9bc57289
...
@@ -3,13 +3,14 @@
...
@@ -3,13 +3,14 @@
## TODO
## TODO
1.
Write "Help" documentation
1.
Write "Help" documentation
2.
Change save to include model
2.
Change save to include model
3.
Fix
RMS. Does not work with taskset in exc 6.4
3.
Fix
QueueStrategy to avoid coupled code (duplicate in all sub-strategies)
## FIXED
## FIXED
1.
Fix issue with taskset not arranging correctly when tasks are added before scheduling algorithm is choosen.
*FIXED*
1.
Fix issue with taskset not arranging correctly when tasks are added before scheduling algorithm is choosen.
*FIXED*
2.
Fix Strategy-based priority assignment
*FIXED*
2.
Fix Strategy-based priority assignment
*FIXED*
3.
Make space between buttons on left and the taskset-list.
*FIXED*
3.
Make space between buttons on left and the taskset-list.
*FIXED*
1.
EDF IS STILL WRONG :( Take into consideration distance to deadline, not just deadline size.
*FIXED*
1.
EDF IS STILL WRONG :( Take into consideration distance to deadline, not just deadline size.
*FIXED*
3.
Added DMS and fixed RMS
*FIXED*
## SUGGESTIONS
## SUGGESTIONS
*- Add Task, Change Task, Remove Task på samma rad*
*- Add Task, Change Task, Remove Task på samma rad*
...
...
gui/menu/DMSStrategyMenuItem.java
0 → 100644
View file @
9bc57289
package
gui.menu
;
import
model.SchedulingModel
;
import
strategy.DMS
;
public
class
DMSStrategyMenuItem
extends
StrategyMenuItem
{
public
DMSStrategyMenuItem
(
SchedulingModel
scheduleMdl
)
{
super
(
scheduleMdl
,
new
DMS
(),
"DMS"
);
}
}
gui/menu/ScheduLearnMenuBar.java
View file @
9bc57289
...
@@ -29,6 +29,7 @@ public class ScheduLearnMenuBar extends JMenuBar {
...
@@ -29,6 +29,7 @@ public class ScheduLearnMenuBar extends JMenuBar {
strategy
.
add
(
new
FPStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
FPStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
EDFStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
EDFStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
RMSStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
RMSStrategyMenuItem
(
scheduleMdl
));
strategy
.
add
(
new
DMSStrategyMenuItem
(
scheduleMdl
));
add
(
file
);
add
(
file
);
add
(
edit
);
add
(
edit
);
...
...
strategy/DMS.java
0 → 100644
View file @
9bc57289
package
strategy
;
import
tasks.Taskset
;
import
tasks.Task
;
import
java.util.Comparator
;
import
java.util.Queue
;
import
java.util.PriorityQueue
;
import
java.util.Map
;
import
java.util.HashMap
;
/*
* class DMS extends QueueStrategy
*
* A Deadline monotonic scheduling class
*/
public
class
DMS
extends
QueueStrategy
{
/*
* Return: Current version of the ready queue according to the DMS strategy
*/
protected
Queue
<
Integer
>
updateQueue
(
Queue
<
Integer
>
q
,
Taskset
ts
,
int
time
)
{
// Lambda creation of complex comparator down below
// compares deadline first and then priority
Comparator
<
Integer
>
order
=
(
Integer
i1
,
Integer
i2
)
->
{
int
res
=
ts
.
getTask
(
i1
).
get
().
deadline
()
-
ts
.
getTask
(
i2
).
get
().
deadline
();
if
(
res
==
0
)
return
i1
-
i2
;
else
return
res
;
};
// Create new Q that uses order comparator and move all current tasks to that Q
Queue
<
Integer
>
internalQ
=
new
PriorityQueue
<>(
order
);
while
(
q
.
size
()
!=
0
)
internalQ
.
add
(
q
.
poll
());
//If we are at a job release, add that much CPU usage to the Q.
for
(
int
taskNbr
:
ts
.
getPriorities
())
{
Task
t
=
ts
.
getTask
(
taskNbr
).
get
();
//I know it exists so I can collect it from the optional directly
if
(
time
%
t
.
period
()
==
0
)
{
for
(
int
i
=
0
;
i
<
t
.
exectime
();
i
++)
{
internalQ
.
add
(
taskNbr
);
}
}
}
return
internalQ
;
}
/*
* Return which Strategy you are using
*/
public
String
toString
()
{
return
"DMS"
;
}
/*
* Return a Comparator for this scheduling strategy
*/
public
Comparator
<
Task
>
prioComparator
()
{
return
new
DMSComparator
();
}
}
strategy/DMSComparator.java
0 → 100644
View file @
9bc57289
package
strategy
;
import
tasks.Task
;
/*
* class DMSComparator implements PriorityComparator:
*
* A comparator class for the Deadline Monotonic Scheduling
*/
public
class
DMSComparator
implements
PriorityComparator
{
/*
* Method compare:
* compares two tasks according to scheduling algorithm.
*
* @param:
* o1 (Object): first object
* o2 (Object): second object
* @return:
* int: comparator output
*/
public
int
compare
(
Object
o1
,
Object
o2
)
{
Task
t1
=
(
Task
)
o1
;
Task
t2
=
(
Task
)
o2
;
if
(
t1
.
deadline
()
==
t2
.
deadline
())
{
return
t1
.
period
()
-
t2
.
period
();
}
return
t1
.
deadline
()
-
t2
.
deadline
();
}
}
strategy/RMS.java
View file @
9bc57289
...
@@ -16,10 +16,14 @@ public class RMS extends QueueStrategy {
...
@@ -16,10 +16,14 @@ public class RMS extends QueueStrategy {
*/
*/
protected
Queue
<
Integer
>
updateQueue
(
Queue
<
Integer
>
q
,
Taskset
ts
,
int
time
)
{
protected
Queue
<
Integer
>
updateQueue
(
Queue
<
Integer
>
q
,
Taskset
ts
,
int
time
)
{
//Create new Q that uses order comparator and move all current tasks to that Q
//Create new Q that uses order comparator and move all current tasks to that Q
//Compares period first and then priority
Comparator
<
Integer
>
order
=
Comparator
<
Integer
>
order
=
(
Integer
i1
,
Integer
i2
)->
(
Integer
i1
,
Integer
i2
)->{
ts
.
getTask
(
i1
).
get
().
period
()
-
time
%
ts
.
getTask
(
i1
).
get
().
period
()
-
int
res
=
ts
.
getTask
(
i1
).
get
().
period
()
-
ts
.
getTask
(
i2
).
get
().
period
();
(
ts
.
getTask
(
i2
).
get
().
period
()
-
time
%
ts
.
getTask
(
i2
).
get
().
period
());
if
(
res
==
0
)
return
i1
-
i2
;
else
return
res
;
};
//NOTE: ADD PRIORITY COMPARISON //
Queue
<
Integer
>
internalQ
=
new
PriorityQueue
<>(
order
);
Queue
<
Integer
>
internalQ
=
new
PriorityQueue
<>(
order
);
while
(
q
.
size
()
!=
0
)
internalQ
.
add
(
q
.
poll
());
while
(
q
.
size
()
!=
0
)
internalQ
.
add
(
q
.
poll
());
...
...
Write
Preview
Supports
Markdown
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