THINK FIRST·CODE LATER

← All labs

HEFT: reproduce a classic result

Problem

Implement HEFT and reproduce the makespan of 80 from the original paper's 10-task example.

Input: the Chapter 6 format (see OS6.1).

Algorithm:

  1. Compute rank_u (as in OS6.1). Priority order: decreasing rank_u; ties → smaller task number.
  2. For each task in that order and each processor k (in order P1, P2, …):
    • ready time = max over predecessors q of (finish(q) + (0 if q runs on k else c(q, i))), or 0 for entry tasks;
    • EST = the earliest start ≥ ready time such that the interval [EST, EST + w(i, k)) fits in an idle gap of k (insertion policy: gaps between already scheduled tasks count; otherwise after the last task);
    • EFT = EST + w(i, k). Choose the processor with the minimum EFT (ties → lowest processor number).

Output:

Upward ranks: T1=... T2=... (two decimals, task order)
Priority order: T1 T3 ...
T1 -> P3 start 0 finish 9        (one line per task, in scheduling order)
...
Makespan: 80
SLR: 1.951 (CP_MIN = 41)
Speedup: 1.588 (best sequential = 127)
Efficiency: 0.529

Times are printed as integers when they are whole numbers, otherwise with two decimals. CP_MIN = the longest path using each task's minimum cost and no communication; best sequential = the minimum over processors of the sum of all task costs on that processor.

The example input is the classic one (10 tasks, 3 processors) — see the test data in the model solution.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.