Re: [PATCH] mailoop-test #2



> This patch also works and sdoesn't rely on g_usleep but on waiting for the
> threads to start and get to the point where they add their context to the
> array before it continues.
> +
> +  while (context_array->len < NTHREADS - 1){}

To be 100% technically correct this isn't guaranteed to work either - if the
compiler puts context_array->len in a register, the looping thread won't see
any updates and it will hang forever... I believe declaring context_array
'volatile' will prevent this, although the 'real' solution is to use an
honest-to-goodness semaphore/condition variable.

Not that this one little piece of code matters so much... If I have some
extra time later I'll see about writing a 100% guaranteed patch...

Sorry, I don't mean to annoy you, I just wince whenever I see buggy threaded
code =). Thanks for doing the FreeBSD porting, BTW!!!

Regards,
Dan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]