[PATCH] minor pthread fixes
Thu Apr 18 04:31:00 GMT 2002
Hi Thomas! It's great to see someone else also interested in pthreads. I
look forward to your work on cancellation - that's been in my TODO list
for far too long.
re: 1. Good catch, this definitely needs fixing. Also an excellent catch
on pthread_join (pthread_self(),...)
Regarding 2:, again a good catch.
I'll commit this to CVS this weekend, I've a bit of spare time coming
> -----Original Message-----
> From: Thomas Pfaff [mailto:firstname.lastname@example.org]
> Sent: Thursday, April 18, 2002 8:11 PM
> To: email@example.com
> Subject: [PATCH] minor pthread fixes
> This patch contains some small pthread fixes:
> 1. the pthread class allocated in __pthread_create never was
> freed. This
> resulted in a memory leak and an unclosed handle.
> Depending on the state of of the thread it is deleted now in
> __pthread_exit or __pthread_join
> 2. The InterlockedIncrement (&MT_INTERFACE->threadcount) in
> __pthread_create is misplaced. If the newly created thread
> fast enough the threadcount will be decremented before it was
> incremented, which will result in an exit from
> __pthread_exit instead
> of an ExitThread.
> Comments are very welcome, because i like to add more patches
> regarding cancellation which is incomplete, a better mutex
> implementation (the current one has only recursive mutexes
> and is slow on win9x) ... .
> 2002-04-18 Thomas Pfaff <firstname.lastname@example.org>
> * thread.h (pthread::joiner): New member.
> * thread.cc (pthread::pthread): Initialize joiner to NULL
> (pthread::create): Increment of thread counter moved from
> __pthread_create to this location.
> (__pthread_create): Increment thread counter removed.
> (thread_init_wrapper): Set joiner to self when thread
> was created
> (__pthread_exit): delete thread when it is detached and not
> (__pthread_join): Check for deadlock and delete thread
> when it has
> (__pthread_detach): Set joiner to self when thread state
> changed to detached.
More information about the Cygwin-patches