Download presentation
Presentation is loading. Please wait.
Published byJob Woods Modified over 9 years ago
1
Planning and Scheduling Chapter 3 Jennifer Holland February 2, 2010
2
Scheduling Tasks Processors – Anything that can perform a task – Humans, robots, or machines Machine-Scheduling Problem – Deciding how to assign task to various processors – Want to achieve earliest completion as possible Tasks must then be prioritized Rules must be in place in cases of “ties” in importance
3
Examples of Prioritizing Visiting an emergency room – Man with a broke leg – Child who will not open one of his eyes – Woman with severe pains in her abdomen – Child with a fever
4
Assumptions and Goals 1.Once a task has begun, the processor will continue with the task until has been complete. 2.If there is an idle processor and a task to be completed, the processor will immediately begin work on the task. 3.Ordering of tasks must as be taken into consideration. 4.In addition to the order of tasks must be done, there is also a priority list which is independent of the first list.
5
Building a House Priority List – Prep site for digging – Dig for foundation – Lay Foundation Order-requirement digraph 8 5 35 7 6 94 T7T7 T2T2 T3T3 T4T4 T6T6 T5T5 T8T8 T1T1
6
List-Processing Algorithm Part I and Ready Task A task is ready if all its predecessors (from digraph) have been completed at that time. At a given time, assign to the lowest-numbered free processor the first task on the priority list that is ready at that time and hasn’t already been assigned to another processor Part II Priority list is scanned from left to right. If no task can be assigned at that time, one or more processors will remain idle until there is a task ready.
7
Using List-Processing Algorithm Order-requirement digraph 8 5 35 7 6 94 T7T7 T2T2 T3T3 T4T4 T6T6 T5T5 T8T8 T1T1 T8T8 T2T2 T5T5 T6T6 T4T4 T7T7 T1T1 T3T3 Priority List: T 8, T 7, T 6, T 5, T 4, T 3, T 2, T 1 057131924272832 Machine 1 Machine 2 Note: Different Priority Lists will produce different schedules with different end times. Idle time
8
When is a Schedule Optimal? An optimal schedule will have the least amount of idle time. The shortest completion time is made up of the path with the longest distance through the order-requirement digraph; T 1, T 2, T 3, T 4 with a length of 27 This distance must be at least as large as the total task times divided by the number of processors—47/2 = 23.5 (actually 24 because the tasks are integer times so the solution must also be integer. 8 5 35 7 94 T7T7 T2T2 T3T3 T4T4 T6T6 T5T5 T8T8 T1T1 6
9
Critical-Path Schedules Before the priority list was given. Now the question is whether or not there is a systematic way of choosing a priority list which will yield an optimal solution
10
How to Obtain Priority List L 1.Find a task that heads a critical (longest) path in the order- requirement digraph. If there is a tie, choose the task with the lower number. 2.Place the task found in step 1 next on the list L. (The first time through the process this task will head the list.) 3.Remove the task found in step 1 and the edges attached to it from the current order-requirement digraph, obtaining a new (modified) order-requirement digraph. 4.If there are no vertices left in the new order-requirement digraph, the procedure is complete; if there are vertices left, go back to step 1. This procedure will terminate when all the tasks in the original order- requirement digraph have been placed on the list L.
11
Priority List L T1T1 Machine 2 T5T5 T6T6 T8T8 T4T4 T9T9 T7T7 T 10 14 416 36 14 4 6 4 T2T2 T3T3 T7T7 T6T6 T4T4 T5T5 T8T8 T9T9 T 10 T 1 T 2 T 3 and T 1 T 4 T 3 are both critical paths of length 64. Machine 1 T1T1 T2T2 T3T3 T1T1 T3T3 T 10 T7T7 T9T9 T8T8 T6T6 T5T5 T4T4 T2T2
12
Bin Packing Anytime you want to arrange objects of various shape or size, bin-packing heuristics can be applied. Next-Fit (NF) place the weights into the first bin until the next weight will not fit, then move on to next bin. First-Fit (FF) put the next weight into the first bin already opened that has room for this weight. If no such bin exists, start a new bin. Worst-Fit (WF) If we are keeping track of how much room remains in open bins, we can put the next item to be packed into the bin that currently has the most room available. Note: All these methods can be carried out quickly but cannot be guaranteed to produce optimal results.
13
More Bin Packing Decreasing-Time Heuristics These are used to address the issue of larger weight items showing up later on in the packing list. First step is to sort the items to be packed in order of decreasing size—assuming that all items are known in advance. Next-Fit Decreasing (NFD) First-Fit Decreasing (FFD) Worst-Fit Decreasing (WFD)
14
Class Exercises Next-Fit (NF) place the weights into the first bin until the next weight will not fit, then move on to next bin. For these exercises, our bins will be able to hold 10 pounds (length of 10) 6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5 Worst-Fit (WF) If we are keeping track of how much room remains in open bins, we can put the next item to be packed into the bin that currently has the most room available. 6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5 First-Fit Decreasing (FFD) put the next weight into the first bin already opened that has room for this weight. If no such bin exists, start a new bin. Our list of 6, 6, 5, 5, 5, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 7, 7, 5, 5, 8, 8, 4, 4, 5 becomes: 8, 8, 7, 7, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 2, 2, 2, 2 Homework problems: 6a-c; 49
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.