public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] pthread_cancel_3-1: rewrite
Date: Mon, 4 Jun 2018 07:50:57 -0400 (EDT)	[thread overview]
Message-ID: <606888679.23984992.1528113057232.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <CAEemH2cLq2kZH2Kb1zXTwnM+jc3MVoTcihV==xbte2Ff-gs6-g@mail.gmail.com>



----- Original Message -----
> Jan Stancek <jstancek@redhat.com> wrote:
> 
> >
> > > ​Maybe add:
> > >     SAFE_PFUNC(pthread_mutex_unlock(&mutex));
> > > here too?​
> >
> > There are no users at this point. Is there an issue having it locked at
> > exit?
> >
> >
> ​Not clear too. But after thinking over, maybe it's not a good idea to use
> pthread_mutex_lock() in this situation.

You're right, it's actually not defined according to POSIX:
  http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutex_lock.html

> 
> The reasons are:
> 1. to avoid dead lock, it's not suggest to lock a mutex twice in one thread
> 2. it's not suggest to lock mutex in thread_A but do unlock in thread_B
> 
> ​So what about using semaphore:

Probably simpler than condition. Anyway, I'll drop my mutex fail in v2.

Thanks,
Jan

      reply	other threads:[~2018-06-04 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 12:59 [LTP] [PATCH] pthread_cancel_3-1: rewrite Jan Stancek
2018-06-04  9:42 ` Li Wang
2018-06-04  9:57   ` Jan Stancek
2018-06-04 11:39     ` Li Wang
2018-06-04 11:50       ` Jan Stancek [this message]

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=606888679.23984992.1528113057232.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox