+ function pointers - know how to translate hashtable.c + structures and unions - layout in memory + method dispatching - dynamic binding of methods class Foo { a (); b (); } class Bar extends Foo { a (); c (); } int main () { Foo f = new Bar (); f.a(); f.b(); f.c(); } - which method a does f use? - how does f find it? + buffer overrun - how to exploit languages with no array bound checking - idea o declare a local array o write past the end of the array, so that we overwrite the return pointer o change the return pointer to point to our own code o run your program with a setuid root program - the point of teaching you this, is it so that you can a. show off to your friends b. hack into systems where you don't have access c. write better programs that can't be exploited in this way - answer: c + performance - are we in a statistics class? - no - then what's the point? - learn how to measure performance so that we can see how caches improve performance - arithmetic means and geometric means Tp = 1/Texec o arithematic mean: ave (Tp) = sum (Tpi) / n = sum (1/Texeci) / n o normalized execution time: Nexec = Texec / Rexec o screws up arithematic means o geometric mean, however, works fine with normalized execution time but do not predict execution time geo (Tp) = nth root of (prod (Nexec)) geo (X) / geo (Y) = geo (X/Y) o not sure how important this is - what's important is AMDAHL'S LAW !!! o if there's one thing to remember out of this class, remember this: execution time after improvement = (execution time affected by improvement / amount of improvement) + execution time unaffected by improvement o Nick promises a problem about this on the midterm o better study o example (P&H 2.41) O Suppose we enhance a machine to make all floating-point instructions run five times faster. Let's look at how speedup behaves when we incorporate the faster floating-point hardware. If the execution time of some benchmark before the floating-point enhancement is 10 seconds, what will the speedup be if half of the 10 seconds is spent executing floating-point instructions? Speed up = Performance after improvement/Performance before improvement Amdahl's Law (again, in case you didn't see it the first time) execution time after improvement = (execution time affected by improvement / amount of improvement) + execution time unaffected by improvement Performance = 1 / Execution time Solution: Performance before improvement = 1/10s = 0.1 Hz execution time after improvement = 5 s + 1 s = 6 s Performance after improvement = 1/6s = 0.166666 Hz Speedup = (1/6s) / (1/10s) = 5/3 = 1.66666 compare: floating point instructions 5 times faster, speedup is 5/3