On Thu, 18 Feb 2010, Maurilio Longo wrote: Hi Maurilio,
> inside vm/thread.c 817..818 there is a comment of yours about DosWaitThread(), > I don't know if this text about it can help you decide what to do. > --------8<-------------- > DosWaitThread is used to wait for termination of threads within a process. It > is usually used so that thread resources (for example, the stack) can be > recovered when a thread ends. DosWaitThread waits on any thread within the > current process, or on a specific thread within the process, based on the ptid > parameter's contents. option allows the caller the option of waiting until a > thread ends, or getting immediate return and status. If no thread has ended > and the DCWW_NOWAIT option is specified, the ptid field is preserved. > > If DosWaitThread is called with the input ptid set to the current thread (the > thread attempts to wait on its own termination), the ERROR_INVALID_THREADID > error code is returned. ERROR_INVALID_THREADID is also returned if a caller > attempts to wait on the termination of the thread with a ptid of 1. > ------->8-------------- Thank you for the information. I know the syntax but AFAIR when we were talking about it last time you said that this function has build in race condition and when thread terminates before other thread calls DosWaitThread() then this function fails with error code set to ERROR_INVALID_THREADID. It's the reason why I added '|| rc == ERROR_INVALID_THREADID' in the line below my TOFIX note: return rc == NO_ERROR || rc == ERROR_INVALID_THREADID; I do not have OS2 so I haven't verified it but because the event interface also has build in race condition when used as conditional variables then it's highly possible I'm not even surprised. Current code does not look nice but it's working so I probably I should replace TOFIX with TOCLEAN or even NOTE to not confuse users. Of course if you know cleaner solution then of course we should implement it. BTW have you noticed that some OS2 ports of open source projects like MySQL have exactly the same bug as early Harbour OS2 MT code? This bug is in PTHREAD emulation code. Looks that it's common that programmers working with other systems do not expect API which has build race conditions and wrongly understand the OS2 documentation. best regards, Przemek _______________________________________________ Harbour mailing list (attachment size limit: 40KB) [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
