All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: "H . J . Lu" <hjl@lucon.org>
Cc: GNU C Library <libc-alpha@sources.redhat.com>, linux-mips@oss.sgi.com
Subject: Re: A linuxthreads bug on mips?
Date: 29 Jan 2002 00:54:41 -0800	[thread overview]
Message-ID: <m3zo2x35bi.fsf@myware.mynet> (raw)
In-Reply-To: <20020125234542.A31028@lucon.org>

"H . J . Lu" <hjl@lucon.org> 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
runnable.

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 redhat.com   `------------------------

  parent reply	other threads:[~2002-01-29  9:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-26  7:45 A linuxthreads bug on mips? H . J . Lu
2002-01-28 15:22 ` Scott A McConnell
2002-01-29  8:54 ` Ulrich Drepper [this message]
2002-01-30  2:41   ` H . J . Lu
  -- strict thread matches above, loose matches on Subject: below --
2002-01-26 16:15 Justin Carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zo2x35bi.fsf@myware.mynet \
    --to=drepper@redhat.com \
    --cc=hjl@lucon.org \
    --cc=libc-alpha@sources.redhat.com \
    --cc=linux-mips@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.