Operaing Sysems SS 00 Universiy of Zurich Operaing Sysems Exercise 3 00-06-4 Dominique Emery, s97-60-056 Thomas Bocek, s99-706-39 Philip Iezzi, s99-74-354 Florian Caflisch, s96-90-55 Table page Table page 3 Exercise 3. /8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich able : 0 3 4 5 6 7 8 9 0 3 4 5 6 7 8 9 FCFS firs-come-firs-served P P RR round-robin (q=) P P RR round-robin (q=4) P P SPN shores-process-nex P P SRT shores-remaining-ime P P HRRN highes-response-raio-nex P P Feedback (q=) P P Feedback (q= i- ) P P /8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich able : Process 3 4 5 Arrival Time 0 3 4 6 Burs Time T S 6 3 5 4 3 4 5 Mean FCFS firs-come-firs-served F 6 8 6 0. T U 6 7 8 4 9.4 T U /T S 3.5.67.4 3.5.6 RR round-robin (q=) F 6 5 0 9 4.4 T U 6 4 9 6 3.6 T U /T S.67 3 3. 3.5.8 RR round-robin (q=4) F 9 6 9 0 7 4. T U 9 5 6 6.4 T U /T S 3.7.5 3..75.7 SPN shores-process-nex F 6 8 0 5 T U 6 7 8 6 9 9. T U /T S 3.5.67 3..5.5 SRT shores-remaining-ime F 5 3 6 0 0 0.8 T U 5 3 6 4 8 T U /T S.5 3..74 HRRN highes-response-raio-nex F 6 8 6 0. T U 6 7 8 4 9.4 T U /T S 3.5.67.4 3.5.6 Feedback (q=) F 0 6 9 7 4.8 T U 0 5 9 5 T U /T S 3.33.5 3 3.75.9 Feedback (q= i- ) F 7 8 0 9 0 4.8 T U 7 7 7 5 4 T U /T S.83 3.5.33 3 3.5 3.03 3/8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich Exercise 3. I/O-bound processes end o use he CPU for shor burs a a ime and heir I/O-burs ime is much longer, so hey usually have used less CPU ime wihin he recen pas han oher processes. So his algorihm favors I/O-bound programs. However, he algorihm akes ino accoun only recen hisory. Like his, CPU-bound processes will no sarve permanenly. If a process does no receive ime quanum for a while, i becomes one of he processes ha had he leas CPU ime in he recen pas and i will ge a chance o use CPU. long CPU burs CPU-bound I/O-bound shor CPU burs recen pas Exercise 3.3 informal argumen: To ge he leas average response ime i is always he bes o le he shor processes run firs and he long ones a he end. The shor ones don need o wai for he long ones and he long ones don affec he average so much. The proporion for he long ones does no ake so much ino accoun. formal proof: Le s consider wo processes p (burs ime ) and p (burs ime ). Boh processes go he same arrival ime. assumpion: < p, p p, p average ime: average ime: avg = + + 4 + = avg = + + 4 + = assumpion: 4 avg + < avg 4 < + 4/8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich 4 4 + proof: + 4 < < + < 4 + < his is also valid for a process sequence wih more han processes: ( x < x+ ) ( x+ < x+ ) x < x+ Exercise 3.4 There s a couple of reasons where he opimal choice is p=: All asks relae on each oher. Task n has o wai for ask n- ; ask n- has o wai for ask n-, They need o be processed in serial order. Wih p= he whole load will be on node and node will be relieved. Using node in his case makes no sense, as anyway he asks need o ge serialized and canno run parallel. Node is no reliable (e.g. i crashed) Node is jus a mirror of Node, so disribuing he asks ono boh nodes doesn give us any advanage in performance coss of Node are much higher han coss of Node (e.g. node has been ousourced) a) remoe accesses Exercise 3.5 Daa Resources R R R3 R4 R5 N 3 3 P P 3 oal: remoe accesses 5/8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich b) opimal g / opimal f given: f = {(,), (,), (3,), (4,), (5,3) Daa Resources R R R3 R4 R5 N????? P P 3 given: g = {(,), (,), (3,3), (4,3), (5,) Daa Resources R R R3 R4 R5 N 3 3 P? P???? opimal g: g = {(,), (, 3), (3,), (4, 3), (5,) number of remoe accesses: R 0 R R3 R4 R5 Toal 6 For he given process-o-node allocaion (f) we chose he opimal node for each resource. We always ook he maximum used node from he f- funcion. A R and R4 i doesn maer which node we ake as we canno preven he oher wo remoe accesses. opimal f: f = {(,3), (,), (3, 3), (4, 3), (5,) number of remoe accesses: P P Toal 6 For he given resource-o-node allocaion (g) we chose he opimal node for each process. We always ook he maximum used node from he g- funcion. A, we should use node,, or 3. A we can chose beween node or 3 as boh of hem are allocaed in he resource-o-node funcion. Like his we re able o keep remoe accesses a he minimum. Like his we re able o keep remoe accesses a he minimum. commen: decisions wih alernaives: Any of he alernaives can be chosen wihou any impac on he number of remoe accesses. 6/8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich c) f given, opimal g (Pseudo-Code): n := amoun(p); m := amoun(r); marix := mn-requiremens marix; // all requiremens are, else 0 // f(x) reurns he node allocaed o process x // g(x) reurns he node allocaed o daa resource x for (i =; i <= n; i++) { for (j = ; j <= m; j++) { if (marix[pi,rj]) { voe for [Rj,node f(pi)]; Daa Resources R R R3 R4 R5 N max_voe max_voe max_voe max_voe max_voe P P 3 3 3 3 for (j = ; j <= m; j++) { g(j) = max_voe([rj,node]); // chooses he node wih he highes voe c) g given, opimal f (Pseudo-Code): n := amoun(p); m := amoun(r); marix := mn-requiremens marix; // all requiremens are, else 0 // f(x) reurns he node allocaed o process x // g(x) reurns he node allocaed o daa resource x for (j =; j <= m; j++) { for (i = ; i <= n; i++) { if (marix[pi,rj]) { voe for [Pi,node g(rj)]; Daa Resources R R R3 R4 R5 N 3 3 P max_voe 3 3 P max_voe 3 max_voe 3 max_voe 3 max_voe 3 for (i = ; i <= n; i++) { f(i) = max_voe([pi,node]); // chooses he node wih he highes voe 7/8 00 Group Hosebei
Operaing Sysems SS 00 Universiy of Zurich d) opimal f and g wih minimal remoe accesses If we would allocae all he processes and all he daa resources o he same node, here would only be local accesses and, of course, ha would be opimal. :) Under he assumpion ha each node ges a leas one process, we need o look for anoher soluion ) creae he P-R-requiremens marix respecively creae a able and mark every field where process accesses a daa resource. ) o sar, all processes and all resources are allocaed o node (defaul value) 3) raverse hrough he whole marix/able and do he following for every marked cell: Calculae he number of marked cells ha would be affeced if we move he curren processresource-pair o anoher node. Choose he allocaion wih he smalles amoun of affeced cells 4) ierae hrough he whole marix/able and repea sep 3) Daa Resources R R R3 R4 R5 N 3 P P 3 oal: 5 remoe accesses f = { (,), (,), (3,), (4,3), (5,) g = { (,), (,), (3,3), (4,), (5,) e) opimal f and g for any given requiremens-marix and number of nodes Follow he insrucions in d) -4 Here we need o assure ha no node ges more han x processes (x: desired amoun of disribuion). Ierae hrough he whole marix/able unil he process coun of node equals x. Also, we do he allocaion wih he smalles amoun of affeced cells o a node whose process coun is less han x. 8/8 00 Group Hosebei