On 09/27/2012 08:32 PM, Tom Tromey wrote: >>>>>> "Ali" == ali anwar writes: > > Ali> +static int > Ali> +thread_valid (struct thread_info *tp) > Ali> +{ > Ali> + struct thread_info *utp; > Ali> + for (utp = thread_list; utp; utp = utp->next) > Ali> + if (tp == utp) > Ali> + return 1; > Ali> + return 0; > Ali> +} > > Ali> + for (tp = thread_list; thread_valid(tp); tp = tp->next) > > It seems like this introduces quadratic behavior here. > I think it would be better to avoid this. > > Ali> + if (thread_count() == 0) > Ali> + break; > > Here too. > > Tom > Please find attached the modified patch. This time the complexity is linear. The thread list is saved first and then it is verified that each thread still exists or not. Testing: * Tested on i686-pc-linux * Also checked with valgrind * Executed the testuite Thanks, -Ali