1

I have a list of Tasks and each Task has a List of Tasks that depends on this Task and a time it takes to finish the task.

I have n processors and am trying to get the quickest time to finish all the Tasks.

For example:

Task 1 -> Tasks 2 and 3 depend it and takes 10 seconds

Task 2 -> no dependent Tasks and takes 5 seconds

Task 3 -> no dependent Tasks and takes 10 seconds

Task 4 -> no dependent Tasks and takes 12 seconds

I have 2 processors.

The quickest time to finish would be 20s. Task 1 and Task 4 are run in parallel. When Task 1 finishes it runs Task 3 and when Task 4 finishes it runs Task 2.

I've thought about first using topological sort to get a list of what tasks need to be completed first and then compare the times of all the tasks that can be run and pick the ones with the longest time and do those first.

Any ideas?

hktir
  • 99
  • 5
  • Possible duplicate of [Algorithm to transform a workflow DAG into parallel resource allocation?](http://stackoverflow.com/questions/3974731/algorithm-to-transform-a-workflow-dag-into-parallel-resource-allocation) – Eyal Shulman May 24 '16 at 14:05
  • @EyalShulman: That problem is related but neither a special case nor a generalisation of this one: Unlike this problem, it imposes constraints on which tasks can be assigned to which processors, but it also assumes each task takes the same time. – j_random_hacker May 24 '16 at 15:33
  • If you pretend you have an infinite number of processors, the shortest completion time is given by the critical path, which can be computed very easily in O(m) time for an m-edge DAG. (This gives you a nice lower bound, BTW.) For a single processor, topological sorting (easily) gives you an optimal solution. I seem to recall reading that the 2-processor variant can be solved optimally in polynomial time, but that for 3 or more processors, the problem is NP-hard :( – j_random_hacker May 24 '16 at 15:36
  • Does this answer your question? [Execution of Directed Acyclic Graph of tasks in parallel](https://stackoverflow.com/questions/63354899/execution-of-directed-acyclic-graph-of-tasks-in-parallel) – Anmol Singh Jaggi May 08 '21 at 15:33

0 Answers0