| OCR Text |
Show 29 loop_detection() { delta_set delta, delta_l, delta_total; int i,counter; Word pc; counter = 1 ; /* the initial estimate of the loop length */ do { delta_total = 0 ; /* initialize target state */ pc = get_pc(); for (i = 0, i < counter, i++) { /* reset target state */ if (get_operation() == READ) { delta.total = 0 ; pc = get_pc(); } get_delta(delta,delta_l); /* read delta, inverse delta */ /* delete, if this is an old pair */ if (delta in delta_total) delta_total -= delta_l; /* add, if this is a new address */ if (!(addr(delta) in addr(delta_total)) && delta != delta_l) delta_total += delta_l; if (delta_total == 0 kk pc == get_pc()) loop_f o u n d O ; /* INFINITE LOOP */ } counter *=2; /* increase the estimate of the loop length */ } while(TRUE); } Figure 2.1. A Director to Detect an Infinite Loop |