Created by Brendan College for EEE 4775 Real-time Systems.
This repository contains an implementation and a simulator of Bratley's scheduling algorithm using only standard libraries (std=C++20). This repository was created for my EEE 4775 Real-time Systems course at the University of Central Florida.
Clone this repository into your desired directory and cd into the project's directory,
git clone https://github.com/myhe01/bratleys.git
cd bratleys
Create the project using make.
make
Finally, you're able to run the simulator with the below command and its arguments.
./bratleys NUM_JOBS [-a minarrival] [-A maxarrival] [-c mincomp] [-C maxcomp] [-d mindeadline] [-D maxdeadline] [-i inputfile] [-s seed]
NUM_JOBSis a positive integer specifying the number of jobs the user wishes to create (not used when specifying an input file)
-aallows the user to set the minimum arrival time of any one job by replacingminarrivalwith a positive integer-Aallows the user to set the maximum arrival time of any one job by replacingmaxarrivalwith a positive integer-callows the user to set the minimum computation time of any one job by replacingmincompwith a positive integer-Callows the user to set the maximum computation time of any one job by replacingmaxcompwith a positive integer-dallows the user to set the minimum absolute deadline of any one job by replacingmindeadlinewith a positive integer-Dallows the user to set the maximum absolute deadline of any one job by replacingmaxdeadlinewith a positive integer-iallows the user to specify an input file-sallows the user to set the seed of the random number generator by replacingseedwith a positive integer
If specific options are not specified, they will default to the following values
| Option | Variable | Default Value |
|---|---|---|
-a |
minarrival |
0 |
-A |
maxarrival |
INT_MAX |
-c |
mincomp |
0 |
-C |
maxcomp |
INT_MAX |
-d |
mindeadline |
0 |
-D |
maxdeadline |
INT_MAX |
-s |
seed |
Current Unix time (seconds) |
Attempting to perform an exhaustive search for a feasible schedule with large numbers of NUM_JOBS (
Execution times and memory allocation were measured for the following options: -A5 -c1 -C3 -d4 -D15 -s6969
NUM_JOBS |
Memory allocated (MB) | Execution time (s) |
|---|---|---|
| 20 | 849.09 | 4.562 |
| 21 | 1,535.88 | 7.818 |
| 22 | 2,251.89 | 11.563 |
| 23 | 3,357.87 | 16.556 |
| 24 | 4,663.83 | 23.042 |
| 25 | 19,638.66 | 103.091 |
| 26 | 34,714.62 | 182.392 |
| 27 | 45,201.29 | 236.625 |
| 28 | n/a | 253.706 |
If the user wishes to specify an input file, a readable file must be located in the directory of the compiled program. If the -i option is passed to specify an input file, NUM_JOBS must not be specified.
Each nonempty line in the input file represents one job to be scheduled. Each line must have comma-seperated values representing the arrival time, computation time, and deadline (in that order).
For example, if the user wishes to schedule the following jobs:
| 0 | 1 | 3 | |
| 2 | 3 | 5 | |
| 3 | 7 | 14 |
The input file (e.g. named input.txt) would contain the following:
0,2,3
1,3,7
3,5,14
And the user would pass the following arguments
./bratleys -i input.txt
It is up to the user to specify which and how many jobs they wish to create (see considerations). Any other options passed are irrelevant, as the jobs to be scheduled are not randomly generated.
Code may be used in accordance with the license.
| Topic | Code | Header |
|---|---|---|
| main | main.cpp |
n/a |
| Job | job.cpp |
job.hh |
| Node | node.cpp |
node.hh |
| Tree | tree.cpp |
tree.hh |
-
Documentation ✔️
- Complete To-do List ✔️
- Complete video demonstration ✔️
-
main ✔️
- Parse user arguments ✔️
- Check arguments for compatibility and correctness ✔️
- Limit arrival times, computation time, and deadlines ✔️
- Create list of random Jobs based on user arguments ✔️
- Create Tree with empty root ✔️
- Determine realizable schedule ✔️
- Print schedule if realizable ✔️
- Determine overall finishing time ✔️
- Tell user if no realizable schedule exists ✔️
- Print schedule if realizable ✔️
- Measure execution time ✔️
- Allow the user to input a list of predetermined jobs ✔️
-
Job ✔️
- Constructor ✔️
- Getters and setters ✔️
- Parse for an ostream ✔️
-
Node ✔️
- Constructor ✔️
- Getters and setters ✔️
- Parse for an ostream ✔️
-
getJobTaskNumber()✔️ -
getJobArrivalTime()✔️ -
getJobComputationTime()✔️ -
getJobDeadline()✔️
-
Tree ✔️
- Constructor ✔️
- Getters and setters ✔️
-
runScheduler()(abstract start of scheduling algorithm) ✔️ -
scheduleJobs()(recursive scheduling algorithm) ✔️- Receive list of Nodes ✔️
- Construct next Node, check if next Node's finish time exceeds deadline ✔️
- If
$f_i > d_i$ , deconstruct the Node and try the next Job from the list ✔️- If list of Jobs exhausted, return up to the parent Node ✔️
- Else continue until list of Nodes is exhausted ✔️
- If
- Return realizable schedule ✔️
Issues are welcome, but pull requests will not be considered. This repository is being built as a class project.
