Re: [AD] 4.9/src/win/wxthread.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Milan Mimica wrote:
Peter Wang wrote:
That introduces another (probably more likely) problem.
_al_thread_create() returns, then it's quite possible that the user then
calls another function which accesses `thread->thread' *before*
thread_proc_trampoline() has filled it in.  So more synchronisation is
needed.

Anyone willing to fix this?  Otherwise into the bug tracker it goes...

CreateThread()?
http://msdn.microsoft.com/en-us/library/ms682453(VS.85).aspx

CreateThread is not recommended (by the MSDN docs) when using CRT... not exactly sure what they are saying there, but it kind of says 'dont bother using this overly complicated function if _beginthreadex() is suffecient'
which i tend to agree with.

the original issue i raised was just the thread handle problem, which the _beginthreadex() does not appear to have, so simply using that instead of the non-ex _beginthread() should solve our problem without introducing a bunch of new issues.

the only major change the ex() adds is that you need to need to call _endthreadex() the minor changes are the return values are different, and the calling convention on the trampoline needs to be changed to __stdcall

i dont see any problem in changing our code to use _beginthreadex() it now seems fairly straight forward.


the new trampoline would be like:

static unsigned int __stdcall trampoline( ... )
{
   .... existing code ....
   _endthreadex( 0 );
    return 0;
}


we also need to manually close the handle with a   CloseHandle( h );
not sure were this should go?
perhaps in the _al_thread_join() ?

aj.
















Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/