21
Optimal Optimal Algorithms for Algorithms for Task Scheduling Task Scheduling Implemented by Implemented by Ala Al-Nawaiseh Ala Al-Nawaiseh Khaled Mahmud Khaled Mahmud

Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Embed Size (px)

Citation preview

Page 1: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Optimal Optimal Algorithms for Algorithms for

Task SchedulingTask SchedulingImplemented byImplemented by

Ala Al-NawaisehAla Al-Nawaiseh

Khaled MahmudKhaled Mahmud

Page 2: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

OutlineOutline

Introduction.Introduction. Algorithms.Algorithms.

In-Forest/Out-Forest by HuIn-Forest/Out-Forest by Hu Interval Order by Papadimitriou & Interval Order by Papadimitriou &

YannakakisYannakakis Two Processor by Coffman & Graham.Two Processor by Coffman & Graham.

Program Design.Program Design. ResultsResults

Page 3: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

IntroductionIntroduction SchedulingScheduling

Set of resources (Processors) and set of Set of resources (Processors) and set of consumers (Tasks)consumers (Tasks)

Gantt Chart.Gantt Chart.

Processor

Time

1 2 3 4 5 0

1

2

3

4

Stop

Start

W-1 W-2 W-3 W-4 W-5

Page 4: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

IntroductionIntroduction

Tasks are represented using Graph, Tasks are represented using Graph, hence the concept Task Graph is hence the concept Task Graph is used.used.

Graph G=(T,E), Graph G=(T,E), Where T=Task, and E= Directed edges.Where T=Task, and E= Directed edges.

The Graph should be a The Graph should be a DAGDAG D: D: DDirectedirected A: A: AAcycliccyclic G: G: GGraphraph

Page 5: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Allowed DAG TypesAllowed DAG Types

In-Forest : for the Hu and Coffman In-Forest : for the Hu and Coffman algorithmsalgorithms

Out-Forest: for the Hu and Coffman Out-Forest: for the Hu and Coffman algorithmsalgorithms

Interval Order: for Papadimitriou and Interval Order: for Papadimitriou and Coffman algorithmsCoffman algorithms

Page 6: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling DAGs without Scheduling DAGs without Considering Considering

CommunicationCommunication Scheduling In-Forests/Out-Forests Scheduling In-Forests/Out-Forests

Task Graphs.Task Graphs. Introduced by Hu.Introduced by Hu. Algorithm 1Algorithm 1

In-Forest Level=Longest path from a node In-Forest Level=Longest path from a node to a Terminal node.to a Terminal node.

Out_Forest Level= Longest path from a Out_Forest Level= Longest path from a node to a start node.node to a start node.

Assign the highest ready task to any Assign the highest ready task to any available processor.available processor.

Page 7: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling In-Forests/Out-Scheduling In-Forests/Out-Forests Task GraphsForests Task Graphs

P1 P2 P3

14 13 11

12 10 9

8 7 5

6 4 2

3

1

141411

121211

131311

111111

101011

9911

8811

7711

6611

5511

3311

2211

4411

1111

Task LevelTask Level

5

4

3

2

1

Page 8: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling DAGs without Scheduling DAGs without Considering Considering

CommunicationCommunication Scheduling Interval Ordered TasksScheduling Interval Ordered Tasks Introduced by Papadimitriou & Introduced by Papadimitriou &

Yannakakis.Yannakakis. Algorithm 2Algorithm 2

Level=The number of all successors.Level=The number of all successors. Assign the highest ready task to any Assign the highest ready task to any

available processor.available processor.

Page 9: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling Interval-Ordered Scheduling Interval-Ordered TasksTasks

P1 P2 P3

6 5 3

4 2

1

4411

3311

5511

1111

2211

6611

Page 10: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling DAGs without Scheduling DAGs without Considering Considering

CommunicationCommunication Two processor SchedulingTwo processor Scheduling Introduced by Coffman & Graham.Introduced by Coffman & Graham.1.1. Assign 1 to one of the terminal tasks.Assign 1 to one of the terminal tasks.2.2. Let labels Let labels 1,2,...,j-11,2,...,j-1 have been assigned. Let have been assigned. Let

SS be the set of unassigned tasks with no be the set of unassigned tasks with no unlabeled successors. We next select an unlabeled successors. We next select an element of element of SS to be assigned label to be assigned label jj. For each . For each node node xx in in SS define define l(x)l(x) as follows: Let as follows: Let y1, y1, y2, ...,yky2, ...,yk be the immediate successors of be the immediate successors of xx. . Then Then l(x)l(x) is the decreasing sequence of is the decreasing sequence of integers formed by ordering the set integers formed by ordering the set {L(y1), {L(y1), L(y2),..., L(yk)}L(y2),..., L(yk)}. Let . Let xx be an element of be an element of SS such that for all such that for all x'x' in in SS, , l(xl(x) ≤ ) ≤ l(x')l(x') (lexicographically). Define (lexicographically). Define L(x)L(x) to be to be jj..

Page 11: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling DAGs without Scheduling DAGs without Considering Considering

CommunicationCommunication3.3. Use Use L(v) L(v) as the priority of task as the priority of task vv

and ties are broken arbitrary. and ties are broken arbitrary.

4.4. Whenever a processor becomes Whenever a processor becomes available, assign it the unexecuted available, assign it the unexecuted ready task with the highest ready task with the highest priority. Ties are broken arbitrarilypriority. Ties are broken arbitrarily..

Page 12: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Scheduling Trees on Two Scheduling Trees on Two processorsprocessors

2211

1111

3311

6611

8811

4411

5511

7711

1 1 1 1 1

1 1

P1 P2

1 2

3 4

6 5

7

8

Page 13: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Program DesignProgram Design

We represented the DAG Graphs We represented the DAG Graphs using Adjacency Matrix.using Adjacency Matrix. A representation of a A representation of a directed graphdirected graph

with n with n verticesvertices using an n × n using an n × n matrixmatrix, , where the entry at (i,j) is 1 if there is an where the entry at (i,j) is 1 if there is an edgeedge from vertex i to vertex j; otherwise from vertex i to vertex j; otherwise the entry is 0. the entry is 0.

Page 14: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Program Flow ChartProgram Flow Chart

Read Input FileBuild Node Informationm

NoError MEssage

Main

Alg = "Hu" ||Alg ="IntervalOrder" ||

Alg="Coffman"

End Alg = ?Hu

Interval Order

Coffman

Graph =In/Out forest Graph =Interval

Order

Graph =DAG

Error MEssage

No

No

Assign LevelSort By Level

Schedu ItOutput

Assign LevelSort By Level

Schedu ItOutput

Assign LevelSort By Level

Schedu ItOutput

End

Page 15: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

ResultsResults

a b c

d e f

h i j

k l

m

g

4 Processors

P1 P2 P3 P4

a b c e

d f g h

i j l

k

m

In-Forest Scheduling on four In-Forest Scheduling on four processors using Hu algorithmprocessors using Hu algorithm

Page 16: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

ResultsResults Out-Forest Scheduling on four Out-Forest Scheduling on four

processors using Hu algorithmprocessors using Hu algorithma b c

d e f

h i j

k l

m

g

4 Processors

P1 P2 P3 P4

m

k l

h i j

d e f g

a b c

Page 17: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Interval Order using Papadimitriou s algorithm

0 0 0

3 2 1

4 5 61

9

1 1

1 1 1

1 1 1

1 2 3

654

7 8

Time P1 P2

123

4 5 6

87 9

P30

1

2

3

ResultsResults

Page 18: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

ResultsResults

a b

c d

e f g

h i

j k

2 Processors

P1 P2

a b

c d

f e

g h

i j

k

DAG using Coffman DAG using Coffman AlgorithmAlgorithm

Page 19: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Sample input file and Sample input file and outputoutput

Input FileInput File============ 11 1411 14a b c d e f g h i a b c d e f g h i

j k j k

0 20 2 1 31 3 2 42 4 2 52 5 3 53 5 3 63 6 4 74 7 4 94 9 5 75 7 5 85 8 6 86 8 7 97 9 7 107 10 8 108 10

Page 20: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

ReferenceReference

Advanced Computer Architecture Advanced Computer Architecture and Parallel Processingand Parallel Processing ByBy

Hesham El-Rewini Hesham El-Rewini Mostafa Abd-El-BarMostafa Abd-El-Bar

Page 21: Optimal Algorithms for Task Scheduling Implemented by Ala Al-Nawaiseh Khaled Mahmud

Thank YouThank You