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
5708fad3
Commit
5708fad3
authored
7 years ago
by
sfphoton
Browse files
Options
Downloads
Patches
Plain Diff
Skeleton with the easier function bodies done
parent
0ea34ee7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Global.java
+29
-0
29 additions, 0 deletions
src/Global.java
src/RR.java
+32
-0
32 additions, 0 deletions
src/RR.java
src/SRTF.java
+21
-0
21 additions, 0 deletions
src/SRTF.java
src/Task.java
+32
-0
32 additions, 0 deletions
src/Task.java
with
114 additions
and
0 deletions
src/Global.java
+
29
−
0
View file @
5708fad3
/**
* the global scheduler
* It will distribute the incoming tasks between the two schedulers (RR & SRTF) and select which one may determine the active task
*/
public
class
Global
{
private
SRTF
srtf
=
new
SRTF
();
//high priority scheduler
private
RR
rr
=
new
RR
();
//low priority scheduler
String
history
=
""
;
//a string with tha names of task that have taken control so far - I will use this only for the output
public
void
add
(
Task
t
)
{
if
(
t
.
isKernel
)
srtf
.
add
(
t
);
else
rr
.
add
(
t
);
}
public
void
tick
()
{
}
/**
* A task is forcibly taking control
* @param t the task to be run
*/
public
void
changeRunning
(
Task
t
)
{
}
}
This diff is collapsed.
Click to expand it.
src/RR.java
+
32
−
0
View file @
5708fad3
import
java.util.PriorityQueue
;
import
java.util.Queue
;
/**
* A round-robin scheduler designed for low priority tasks - so it can be stopped when a higher priority task comes in and restarted later.
*/
public
class
RR
{
private
static
final
int
timeSlice
=
2
;
//time in ticks while a task is allowed to run
private
int
runningFor
=
0
;
//the number of timeslices the active task has been running for
private
Queue
<
Task
>
waitingQueue
=
new
PriorityQueue
<>();
//inactive tasks
private
Task
activeTask
;
//the active task; null if there are none
public
void
start
()
{
}
public
void
stop
()
{
}
public
void
add
(
Task
t
)
{
waitingQueue
.
add
(
t
);
}
/**
* signals a processor tick
*/
public
void
tick
()
{
}
}
This diff is collapsed.
Click to expand it.
src/SRTF.java
+
21
−
0
View file @
5708fad3
import
java.util.PriorityQueue
;
import
java.util.Queue
;
/**
* An SRTF (shortest remaining time first) scheduler designed for high priority tasks
*/
public
class
SRTF
{
private
Queue
<
Task
>
waitingQueue
=
new
PriorityQueue
<>();
//inactive tasks
private
Task
activeTask
;
//active task; null if there are none
public
void
add
(
Task
t
)
{
waitingQueue
.
add
(
t
);
}
/**
* signals a processor tick
*/
public
void
tick
()
{
}
}
This diff is collapsed.
Click to expand it.
src/Task.java
+
32
−
0
View file @
5708fad3
/**
* A task to be scheduled in the model
*/
public
class
Task
{
public
final
char
name
;
public
final
boolean
isKernel
;
public
final
int
startTime
;
public
int
remainingTime
;
private
int
waitingTime
=
0
;
public
Task
(
char
name
,
boolean
isKernel
,
int
start
,
int
duration
)
{
this
.
name
=
name
;
startTime
=
start
;
remainingTime
=
duration
;
this
.
isKernel
=
isKernel
;
}
/**
* makes the task wait for one tick
*/
public
void
waitOne
()
{
waitingTime
++;}
public
int
getWaitingTime
()
{
return
waitingTime
;
}
/**
* makes the task run for one tick
*/
public
void
runOne
()
{
remainingTime
--;}
}
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