[Top] [All Lists]

Re: A linuxthreads bug on mips?

To: "H . J . Lu" <>
Subject: Re: A linuxthreads bug on mips?
From: Ulrich Drepper <>
Date: 29 Jan 2002 00:54:41 -0800
Cc: GNU C Library <>,
In-reply-to: <>
References: <>
Reply-to: (Ulrich Drepper)
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.5 (asparagus)
"H . J . Lu" <> writes:

> Here is a modified ex2.c which only uses one conditional variable. It
> works fine on x86. But it leads to dead lock on mips where both
> producer and consumer are suspended. Is this testcase correct?

Only if you assume fair scheduling which is not necessarily the case.
Assume the put() function has to stop because the buffer is full.  The
get() function now reads.  It can read everything.  Calling
pthread_cond_signal() does not mean that the put() function gets
running.  Instead get() keeps running and exhausts the input buffer
and then gets in the

    while (b->writepos == b->readpos)
      pthread_cond_wait (&b->notempty, &b->lock);
loop where it can wake up immediately.  put() never is required to be

Therefore your revised code is not acceptable although it probably
will almost always work.

---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at   `------------------------

<Prev in Thread] Current Thread [Next in Thread>