At Tue, 10 Jan 2012 16:01:17 +0800,
Liu Yuan wrote:
> 
> On 01/10/2012 03:52 PM, MORITA Kazutaka wrote:
> 
> > At Sat,  7 Jan 2012 14:29:02 +0800,
> > Liu Yuan wrote:
> >>
> >> From: Liu Yuan <[email protected]>
> >>
> >> We do nothing while we hold the mutex, then we don't need it.
> >>
> >> Signed-off-by: Liu Yuan <[email protected]>
> >> ---
> >>  sheep/work.c |    4 ----
> >>  1 files changed, 0 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/sheep/work.c b/sheep/work.c
> >> index 789272e..de3f500 100644
> >> --- a/sheep/work.c
> >> +++ b/sheep/work.c
> >> @@ -194,10 +194,6 @@ static void *worker_routine(void *arg)
> >>    struct work *work;
> >>    eventfd_t value = 1;
> >>  
> >> -  pthread_mutex_lock(&wi->startup_lock);
> >> -  /* started this thread */
> >> -  pthread_mutex_unlock(&wi->startup_lock);
> >> -
> > 
> > This lock is used to ensure that all worker threads are correctly
> > started up.
> > 
> 
> 
> Why we need mutex here to ensure correct start-up? We get the lock, do
> nothing and then unlock, looks a null operation to me.

If we don't wait start-up here and pthread_create fails in
init_work_queue(), a deadlock could happen.  It is because
init_work_queue() waits for the already running threads with
pthread_join() but the threads would suspend with pthread_cond_wait().

If we can cleanly exit init_work_queue() in error cases, I think it is
okay to remove the startup lock.

Thanks,

Kazutaka
-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to