lockless thread management in libports (was: [PATCH] libports: fix the thread counts in case the thread creation fails)

2013-11-11 Thread Justus Winter
Hi :) > > > It might be a good idea use atomic operations instead of the spin lock > > > (which is what the spin lock is using behind the scenes anyways). > > > > It may not be possible: further down there is a decision taken depending > > on totalthreads/nreqthreads becoming 1, and thus you need

Re: [PATCH] libports: fix the thread counts in case the thread creation fails

2013-11-10 Thread Neal H. Walfield
At Sun, 10 Nov 2013 11:54:20 +0100, Samuel Thibault wrote: > > Neal H. Walfield, le Sun 10 Nov 2013 11:38:04 +0100, a écrit : > > At Sat, 9 Nov 2013 18:21:51 +0100, > > Samuel Thibault wrote: > > > > + pthread_spin_lock (&lock); > > > > + totalthreads--; > > > > +

Re: [PATCH] libports: fix the thread counts in case the thread creation fails

2013-11-10 Thread Samuel Thibault
Neal H. Walfield, le Sun 10 Nov 2013 11:38:04 +0100, a écrit : > At Sat, 9 Nov 2013 18:21:51 +0100, > Samuel Thibault wrote: > > > + pthread_spin_lock (&lock); > > > + totalthreads--; > > > + nreqthreads--; > > > + pthread_spin_unlock (&lock); > > It might be a good idea us

Re: [PATCH] libports: fix the thread counts in case the thread creation fails

2013-11-10 Thread Neal H. Walfield
At Sat, 9 Nov 2013 18:21:51 +0100, Samuel Thibault wrote: > > + pthread_spin_lock (&lock); > > + totalthreads--; > > + nreqthreads--; > > + pthread_spin_unlock (&lock); It might be a good idea use atomic operations instead of the spin lock (which is what the spin lo

Re: [PATCH] libports: fix the thread counts in case the thread creation fails

2013-11-09 Thread Samuel Thibault
Justus Winter, le Sat 09 Nov 2013 14:21:09 +0100, a écrit : > Previously the number of total threads and the number of unused > threads was wrong if at one point the creation of a thread failed. Fix > this by decrementing both counters that were previously optimistically > incremented. Adjust the c

[PATCH] libports: fix the thread counts in case the thread creation fails

2013-11-09 Thread Justus Winter
Previously the number of total threads and the number of unused threads was wrong if at one point the creation of a thread failed. Fix this by decrementing both counters that were previously optimistically incremented. Adjust the comment accordingly. * libports/manage-multithread.c (ports_manage_p