Skip to content

Commit

Permalink
implement utilization calc
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-l committed Mar 10, 2020
1 parent 4f8172d commit 4c3a679
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
Horologa
=

Determine the frame length and hyper period to be used in a static clock-driven scheduler.
Determine the utilization, hyper period, and frame length to be used in a static clock-driven scheduler.

## Utilization

This program calculates the rate-monotonic utilization of a set of tasks.

Liu & Layland (1973) proved that for a set of n period tasks with unique periods, a feasible schedule that will always meet deadlines exists if the CPU utilization is below a specific bound (depending on the number of tasks). The scheduling test for this is the following equation:

Utility = sum i = 1 to n [e_i/c_i] <= (2^(1/n) - 1)

## Hyper Period

Expand Down
3 changes: 3 additions & 0 deletions cmd/horologa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func main() {
os.Exit(horologa.Errors.FailedToDetermineHyperPeriod.Code)
}

utilzation := horologa.DetermineUtilization(tasks)

fmt.Println("Hyper Period:", hyper_period)
fmt.Println("Frame Length:", frame_length)
fmt.Println("Utilization:", utilzation)
}
15 changes: 15 additions & 0 deletions internal/horologa/horologa.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package horologa

import (
"errors"
"fmt"
)

// helper function to determine the gcd
Expand Down Expand Up @@ -123,3 +124,17 @@ func DetermineHyperPeriod(tasks Tasks) (int, error) {

return hyper_period, nil
}

/* Utilization - this function returns 1 if the set of tasks
completely utilize the 'processor' => utilization = 1 means
the schedule is optimal.
*/
func DetermineUtilization(tasks Tasks) (float64) {
var utilization float64 = 0

for _, task := range tasks.T {
utilization += float64(task.ExecutionTime)/float64(task.Period)
}

return utilization
}
6 changes: 3 additions & 3 deletions tasks.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"tasks": [
{"phase": 0, "period": 4, "executionTime": 2, "relativeDeadline": 4},
{"phase": 0, "period": 4, "executionTime": 1, "relativeDeadline": 4},
{"phase": 0, "period": 5, "executionTime": 2, "relativeDeadline": 5},
{"phase": 0, "period": 20, "executionTime": 1, "relativeDeadline": 20},
{"phase": 0, "period": 20, "executionTime": 2, "relativeDeadline": 20}
{"phase": 0, "period": 20, "executionTime": 1, "relativeDeadline": 10},
{"phase": 0, "period": 15, "executionTime": 2, "relativeDeadline": 15}
]
}

0 comments on commit 4c3a679

Please sign in to comment.