From eff718df52ffeb21bff6b59a5584e5b641887832 Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Mon, 25 Nov 2013 16:00:17 -0500 Subject: Add example code and related end-to-end tests. --- example/mapping.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 example/mapping.py (limited to 'example/mapping.py') diff --git a/example/mapping.py b/example/mapping.py new file mode 100644 index 0000000..513100b --- /dev/null +++ b/example/mapping.py @@ -0,0 +1,28 @@ +#Necessary includes and stuff + +from schedcat.mapping.rollback import Bin, WorstFit +from schedcat.model.tasks import SporadicTask, TaskSystem + +def partition_tasks(cluster_size, clusters, dedicated_irq, + taskset): + first_cap = cluster_size - 1 if dedicated_irq \ + else cluster_size + first_bin = Bin(size=SporadicTask.utilization, + capacity=first_cap) + other_bins = [Bin(size=SporadicTask.utilization, + capacity=cluster_size) + for _ in xrange(1, clusters)] + heuristic = WorstFit(initial_bins=[first_bin] + other_bins) + heuristic.binpack(taskset) + if not (heuristic.misfits): + clusts = [TaskSystem(b.items) for b in heuristic.bins] + for i, c in enumerate(clusts): + if i == 0 and dedicated_irq: + c.cpus = cluster_size - 1 + else: + c.cpus = cluster_size + for task in c: + task.partition = i + return [c for c in clusts if len(c) > 0] + else: + return False -- cgit v1.2.2