1 / 29

Job Scheduling Problem: Planning and Prioritization

Learn about scheduling a job made up of smaller tasks that require different processors, considering priorities and order requirements.

cbritt
Download Presentation

Job Scheduling Problem: Planning and Prioritization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3 Planning and Scheduling

  2. A New Kind of Problem • A job can be made up of a number of smaller tasks that can be completed by a number of different “processors.” • The processors can be machines, robots, humans, or a combination of any of these, depending on the job. • Each task is associated with an amount of time that is required to complete the tasks. • In addition, some tasks will need to be complete before others. • The problem is scheduling: which processor should work on which job at which time?

  3. Assumptions • To simplify the problem, we will make some assumptions. • If a processor starts a task, it will work on that task until the task is complete. • No processor will be voluntarily idle: if there is a processor free and a task ready, that processor will immediately begin work on that task. • There is an order-requirement graph that indicates which tasks must be completed before others. • The tasks are arranged in a priority list that is independent of the order requirements. The priority list indicates which tasks are “most important” and is used to break ties when multiple tasks are ready at a given time.

  4. Goals • Usually, the goal of the scheduling problem is to schedule the processors so that all tasks are complete as early as possible. • However, sometimes we will be interested in minimizing idle time, or minimizing the number of processors needed to finish all tasks by a given deadline.

  5. An Example • Consider the order-requirement graph shown below. There are 8 tasks to be completed. • Suppose there are 2 processors, and the priority list is T8, T7, T6, …, T1, so that T8 is the most important task, and T1 is the least important. Task 7 Task 8 5 5 7 8 9 3 4 6 Task 5 Task 6 Task 1 Task 2 Task 3 Task 4

  6. Assigning the First Task • The job starts at time 0. There are two processors, and both are available. Processor 1 gets to choose first, but it needs to choose a ready task. • Tasks 1, 7, and 8 are ready, since they have no prerequisites. The other tasks are not ready since their prerequisites have not been completed. Task 7 Task 8 5 5 7 8 9 3 4 6 Task 5 Task 6 Task 1 Task 2 Task 3 Task 4

  7. Breaking the Tie: Priority • Which of the three ready tasks should Processor 1 work on? Task 8 comes first on the priority list, so it is the most important. Processor 1 chooses Task 8. • Processor 2 is also available at time 0. Task 8 has already been chosen, so Processor 2 chooses the ready task with the highest priority: Task 7. Task 7 Task 8 5 5 7 8 9 3 4 6 Task 5 Task 6 Task 1 Task 2 Task 3 Task 4

  8. The Timeline • In order to keep track of which tasks have been completed at any given time, we draw a timeline. • Whenever a processor performs a task, we draw a box labeled with the task name on that processor’s line. • The left side of the box is lined up with the start time on the timeline, and the right side is lined up with the end time. Processor 1 Processor 2 0

  9. Time 0 5 7 • Processor 1 works on Task 8 from time 0 to time 7. • Processor 2 works on Task 7 from time 0 to time 5. • In our diagrams, red tasks are being worked on, grey tasks are complete, and green tasks have not yet begun. Task 7 Task 8 Task 5 Task 6 8 Task 1 Task 2 Task 3 Task 4 Task 8 Processor 1 9 3 5 6 4 Task 7 Processor 2 7 0 5

  10. Time 5 5 7 • At time 5, Processor 2 is available. The only ready task is Task 1. Task 7 Task 8 Task 5 Task 6 8 Task 1 Task 2 Task 3 Task 4 Task 8 Processor 1 5 4 3 6 9 Task 7 Task 1 Processor 2 7 0 5 13

  11. Time 7 5 7 • At time 7, Processor 1 becomes available. However, there is no ready task! Task 2 is not ready because task 1 must be complete before Task 2 can begin. Task 7 Task 8 Task 5 Task 6 8 Task 1 Task 2 Task 3 Task 4 Task 8 Processor 1 9 3 5 6 4 Task 7 Task 1 Processor 2 0 5 7 13

  12. Time 13 5 7 • At time 13, both processors are available, and Task 2 is ready. Processor 1 gets to choose first, and works on Task 2. However, there is no other remaining task for Processor 2. Task 7 Task 8 Task 5 Task 6 8 6 Task 1 Task 2 Task 3 Task 4 Task 8 Task 2 Processor 1 4 9 5 3 Task 7 Task 1 Processor 2 0 5 7 13 19

  13. Time 19 5 7 • At time 19, Task 2 is complete, and both processors are available. Tasks 3 and 5 are ready, and Processor 1 gets first pick. Since Task 5 is more important, Processor 1 chooses it. Processor 2 works on Task 3. Task 7 Task 8 5 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 8 Task 2 Processor 1 4 3 Task 7 Task 1 Task 3 Processor 2 28 0 5 7 13 19

  14. Time 24 5 7 • At time 24, Processor 1 completes Task 5. Task 6 is the only ready task, so Processor 1 begins work on it. Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 8 Task 2 Task 5 Task 6 Processor 1 4 Task 7 Task 1 Task 3 Processor 2 24 27 28 0 5 7 13 19

  15. Time 27 5 7 • At time 27, Processor 1 completes Task 6. Since Task 3 still is not complete, Task 4 is not ready, so Processor 1 must be idle. Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 8 Task 2 Task 5 Task 6 Processor 1 4 Task 7 Task 1 Task 3 Processor 2 24 27 28 0 5 7 13 19

  16. Time 28 5 7 • At time 28, Processor 2 completes Task 3, and both processors are available. • Processor 1 gets to choose first, and chooses the only task remaining: Task 4. Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 4 Task 3 Task 4 Task 8 Task 2 Task 5 Task 6 Task 4 Processor 1 Task 7 Task 1 Task 3 Processor 2 24 27 28 32 0 5 7 13 19

  17. Time 32 5 7 • At time 32, all tasks are complete! Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 4 Task 3 Task 4 Task 8 Task 2 Task 5 Task 6 Task 4 Processor 1 Task 7 Task 1 Task 3 Processor 2 24 27 28 32 0 5 7 13 19

  18. Priority Makes a Difference • You may have noticed that our solution had a lot of idle time. Since we were following the priority list, we were forced to complete the tasks in that order. • However, watch what happens when we use a different priority list: T1, T2, T3, …, T8.

  19. Time 0 5 7 Task 7 Task 8 Task 5 Task 6 8 Task 1 Task 2 Task 3 Task 4 Task 1 Processor 1 9 3 5 6 4 Task 7 Processor 2 0 5 8

  20. Time 5 5 7 Task 7 Task 8 Task 5 Task 6 8 Task 1 Task 2 Task 3 Task 4 Task 1 Processor 1 9 3 5 6 4 Task 7 Task 8 Processor 2 12 0 5 8

  21. Time 8 5 7 Task 7 Task 8 Task 5 Task 6 8 6 Task 1 Task 2 Task 3 Task 4 Task 1 Task 2 Processor 1 9 3 5 4 Task 7 Task 8 Processor 2 12 14 0 5 8

  22. Time 12 5 7 Task 7 Task 8 Task 5 Task 6 8 6 Task 1 Task 2 Task 3 Task 4 Task 1 Task 2 Processor 1 3 4 9 5 Task 7 Task 8 Processor 2 12 14 0 5 8

  23. Time 14 5 7 Task 7 Task 8 5 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 1 Task 2 Task 3 Processor 1 3 4 Task 7 Task 8 Task 5 Processor 2 12 14 19 23 0 5 8

  24. Time 19 5 7 Task 7 Task 8 5 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 1 Task 2 Task 3 Processor 1 3 4 Task 7 Task 8 Task 5 Task 6 Processor 2 12 14 19 22 23 0 5 8

  25. Time 22 5 7 Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 Task 3 Task 4 Task 1 Task 2 Task 3 Processor 1 4 Task 7 Task 8 Task 5 Task 6 Processor 2 12 14 19 22 23 0 5 8

  26. Time 23 5 7 Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 4 Task 3 Task 4 Task 1 Task 2 Task 3 Task 4 Processor 1 Task 7 Task 8 Task 5 Task 6 Processor 2 12 14 19 22 23 27 0 5 8

  27. Time 27 5 7 Task 7 Task 8 5 3 Task 5 Task 6 8 6 Task 1 Task 2 9 4 Task 3 Task 4 Task 1 Task 2 Task 3 Task 4 Processor 1 Task 7 Task 8 Task 5 Task 6 Processor 2 12 14 19 22 23 27 0 5 8

  28. List-Processing Algorithm • This method for assigning tasks is known as the list-processing algorithm. The basic rule for the algorithm is: • At any given time, assign to a processor the first task on the priority list that is ready.

  29. Critical-Path Analysis • Note that the critical path (indicated in red on the diagram) has a total length of 27 time units. This means that all eight tasks could not have been completed in less than 27 time units, no matter how many processors we use. Task 7 Task 8 5 5 7 3 Task 5 Task 6 8 6 Task 1 Task 2 9 4 Task 3 Task 4

More Related