Docsity

Ten Puzzling Problems in Computer Engineering - Lecture Slides | PHYS 1, Study notes of Physics

Partial preview of the text

Download Ten Puzzling Problems in Computer Engineering - Lecture Slides | PHYS 1 and more Study notes Physics in PDF only on Docsity!

May 2009^

Task Scheduling

Slide 1

Task Scheduling^ A Lecture in CE Freshman Seminar Series:Ten Puzzling Problems in Computer Engineering

May 2009^

Task Scheduling

Slide 2

About This Presentation Edition^

Released

Revised

Revised

First^

May 2007

May 2008

May 2009

This presentation belongs to the lecture series entitled“Ten Puzzling Problems in Computer Engineering,”devised for a ten-week, one-unit, freshman seminarcourse by Behrooz Parhami, Professor of ComputerEngineering at University of California, Santa Barbara.The material can be used freely in teaching and othereducational settings. Unauthorized uses, including anyuse for financial gain, are prohibited.

©^ Behrooz Parhami

May 2009^

Task Scheduling

Slide 4

Mini-Sudoku Puzzle: Solution Method Complete entries in thischart so that letters A-Fappear without repetitionin each row, each columnand each 2^ ×^ 3 block To continue from here, writedown all possible choices inthe remaining blank boxesand see whether the resultinginfo leads to more progress

(^2) C 4

C^1

6 D B^ A

31 53

D^

6

4 C

6 A^3

D D B^ D

A

F^

C^ A^ E^ C

F

D^

F^ C

SuDoKu: abbr. in Japanesefor “numbers must be single.”Euler may have invented it;Howard Garns (

US) & Wayne

Gould (HK

) popularized it in

modern times

AE AE

May 2009^

Task Scheduling

Slide 5

Sudoku Puzzle: Easy Example

5 4

(^6 ) 7 4 9 5

2 6

1

3 6 4 9

8 5

7 1 3 6

2

9 8

8

3 5 9

(^4 )

5 6

Complete entries in thischart so that numbers 1-9appear without repetitionin each row, each columnand each 3

×^ 3 block

Many newspapers carry thesepuzzles; there are also manycollections in book form Sudoku puzzles of varyingdifficulties (easy, medium,hard, evil) are available at http://www.websudoku.com and several other Web sites,such as USA Today’s site http://puzzles.usatoday.com

May 2009^

Task Scheduling

Slide 7

Sudoku Puzzle: Hard Example

(^6 )

(^85)

5 6 4

(^3 )

4 2

1

1 7 9

8 5 9

3 9 6

1 2

Complete entries in thischart so that numbers 1-9appear without repetitionin each row, each columnand each 3

×^ 3 block

Hard puzzles typically havefewer entries supplied, witheach row, column, or blockcontaining only a few entries Hard puzzles may havehandles or starting points (5 in the top left block or 9 incenter and lower right blocks)

May 2009^

Task Scheduling

Slide 8

Constructing a (Mini-)Sudoku Puzzle Begin with a completedpuzzle and one by oneremove selected entriesthat can be deducedfrom the remaining ones This will ensure a uniquesolution, which is adesirable attribute

(^23) 4

3 1

6 2 1

31 53

6

4 3

4 6 3 2 4

1

6

1 3

6

4

5 62 3 4 3

4

Interesting fact: In a 9^ ×^ 9 Sudoku puzzle,you may need at least 17initial entries (clues) forthe solution to be unique; no one knows whether a 16-clue puzzle withunique solution exists http://people.csse.uwa.edu.au/gordon/sudokumin.php (Web page devoted to minimum Sudoku)

1 4

May 2009^

Task Scheduling

Slide 10

Task Scheduling Problem

We have a set of of tasks

Numbers in Sudoku puzzle

There are some “processors”that can execute tasks

Cells in Sudoku puzzle canhold numbers

Assign tasks to processors soas to meet certain constraints

Place numbers in cells whilehonoring some constraints

A task may fit only some processors Tasks may have prerequisite tasks Preemption may (not) be allowed Tasks may have deadlines Shortest schedule may be required

Use only numbers 1-9 Some numbers already placed Different numbers in each row Different numbers in each column Different numbers in each block

Virtually all instances of the task scheduling problemare difficult (NP-complete), just like Sudoku

May 2009^

Task Scheduling

Slide 11

Resource Allocation Problem

We have a set of of resources

Numbers in Sudoku puzzle

There are “locations” whereresources may be placed

Cells in Sudoku puzzle canhold numbers

Assign resources to locationsto meet certain constraints

Place numbers in cells whilehonoring some constraints

A resource may fit only some locations Resources must be “easily” accessible Resource mobility may (not) be allowed Resource cost may differ by location Lowest-cost assignment may be desired

Use only numbers 1-9 Some numbers already placed Different numbers in each row Different numbers in each column Different numbers in each block

Virtually all instances of the resource allocation problemare difficult (NP-complete), just like Sudoku

May 2009^

Task Scheduling

Slide 13

Scheduling RequiredCE Courses ConstraintsPrerequisite:^ Solid downward arrow Corequisite:^ Dashed sideways arrow Units per quarter:

≤^18

ECE 1

CS 130A

ECE 15A ECE 15B

CS 170

Math 3A Math 3B Math 3C

Math 5A

CS 10 CS 20 CS 40^

CS 60

Phys 1 Phys 2 Phys 3 Phys 4 Phys 3L Phys 4L

Chem 1A Chem 1B

Chem 1AL Chem 1BL^ ECE 2A^ ECE 2B^ ECE 2C ECE 152A ECE 152B ECE 154

Units^12345 Upper -divisionstanding^ Engr 101

ECE 139

Or CS 30Or PSTAT 120A

Or CS 30 Almost done!

12 units 16 20 units

May 2009^

Task Scheduling

Slide 14

Job-Shop Scheduling

Time

86 S^ Tb1t a 4 f f 2 0

Tc

Ta

Ta

Td2^ Tb2^ Tb

Td

Job^ Task Machine Time Staff Ja^ Ta^

M1^2

Ja^ Ta^

M3^6

Jb^ Tb^

M2^5

Jb^ Tb^

M1^3

Jb^ Tb^

M2^3

Jc^ Tc^

M3^4

Jd^ Td^

M1^5

Jd^ Td^

M2^2

M1^ M

M^

Time

86 S t a 4 f f 2 Tb1 0

Tc

Ta

Ta

Td2^ Tb2^ Tb

Td

May 2009^

Task Scheduling

Slide 16

Truck Scheduling

SeattlePortland^ Boise

Dallas

NYC Chicago

Orlando

SF LA

Required trip 00% Truck load

Truck location

May 2009^

Task Scheduling

1 2 Slide 17 (^345) 76 8

9 x x (^1011) x y Vertex v representsTask or Computation j

T^ Latency with p p

r T^ Number of nodesT^ Depth of the gra

p 1 Output 2

p 1 ^31 j

(^1213) Vertex^ v^ representstask or computation j^^ j

T^ Latency with p proc

e T^ Number of nodes (

h T^ Depth of the graph

( p 1 ∞ Output

Multiprocessor Scheduling Task graph with unit-time tasks Here’s a heuristic known as list scheduling:1. Find the depth T = 8 (execution time goal)∞^ Latest start times: see the layered diagramPriorities: shown on the diagram in red

T of the task graph∞^

2. Take^ T

as a goal for the running time∞

Tp

3. Determine the latest possible start times4. Assign priorities in order of latest times

When two tasks have the same “latest starttime,” a secondary tie-breaking rule is used