hw10solutions - CSE 331 Spring 2008 Section 1 Homework 10...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 331 Spring 2008, Section 1 Homework 10 Solutions 1. There may be a few holes in this proof, but it gets the idea across. In the multiprocessor case, the total completion for all jobs can be represented by the sum of the completion times for each processor: C =∑ A = 1 P C A , where each C A =∑ k = 1 N A N A k 1 t k , A . The greedy scheduling algorithm will schedule jobs in such a way that whenever t i,A < t j,B , it must be true that i < j or A < B . It will also fill out each successive value of i , so that the number of jobs on any two processors A and B cannot differ by more than 1. When they do differ, N A > N B if and only if A < B . We will now show that no other schedule can do better. By the proof for the single-processor case, a schedule cannot be optimal if for any A , i , and j , t i,A < t j,A while i > j . By some math that has been excluded for readability's sake, a schedule cannot be optimal if there are two processors A and B such that N A + 2 N B . If this were the case, the total completion time could be reduced by moving the first job from processor B onto processor A . Now say that the greedy algorithm does not yield an optimal schedule. This means that there is some other, better schedule where t i,A < t j,B for some i > j or some A > B (if i = j ). Say that we swap the two jobs. Since none of the other jobs are affected, we can express the cost of the original optimal schedule in terms of some constant X , where C = X  N A i 1 t i, A  N B j 1 t j , B . The cost of the schedule where the jobs are swapped is then C ' = X  N A i 1 t j , B  N B j 1 t i, A . By substitution, this gives us C ' = C  N A N B i j t j , B  N B N A i j t i , A = C  N A N B  j i  t j , B t i , A . We know that t j, B t i, A is positive since t i,A < t j,B . The question is whether the first term is positive, negative, or zero. This can be decided by the following cases: It will be negative if j < i and ( N A N B ), or if j = i and ( N A < N B ). This means that this “optimal” schedule can be improved. This would contradict our assumption that the greedy algorithm did not yield an optimal schedule. It will be zero if
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/25/2008 for the course CSE 331 taught by Professor M.mccullen during the Spring '08 term at Michigan State University.

Page1 / 5

hw10solutions - CSE 331 Spring 2008 Section 1 Homework 10...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online