diff --git a/README.md b/README.md index 2b6b721..d5a7c2c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/horologa/main.go b/cmd/horologa/main.go index a56935e..fb5ccd2 100644 --- a/cmd/horologa/main.go +++ b/cmd/horologa/main.go @@ -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) } diff --git a/internal/horologa/horologa.go b/internal/horologa/horologa.go index 0ca4a6a..b9f9c47 100644 --- a/internal/horologa/horologa.go +++ b/internal/horologa/horologa.go @@ -2,6 +2,7 @@ package horologa import ( "errors" + "fmt" ) // helper function to determine the gcd @@ -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 +} diff --git a/tasks.json b/tasks.json index 2c74bee..dadb810 100644 --- a/tasks.json +++ b/tasks.json @@ -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} ] }