Re: A linuxthreads bug on mips?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"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   `------------------------


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux