public inbox for
 help / color / mirror / Atom feed
From: "ross.johnson" <>
To:, Ger Hobbelt <>
Subject: RE: Aw: Re: Problems with conditions
Date: Wed, 31 Mar 2021 12:30:39 +1100	[thread overview]
Message-ID: <96626b$> (raw)
In-Reply-To: <trinity-b07c66a2-6bbf-4200-941a-19c30109804a-1617118631104@3c-app-gmx-bs44>

That should not make any difference (unless there's a bug in the pthreads implementation). In pthreads-win32 the ERRORCHECK CV uses the ERRORCHECK mutex which adds checks to ensure the unlocking thread owns the mutex lock. (ERRORCHECK isn't meant to be used in production code btw). That it does make a difference, ie your code now works, suggests there is a dependency on timing between the threads that you need to have control of.The code that you included in your first email never sets the condition variable itself before signaling and does not check the condition variable after waking. The example shown in the link that Ger provided does both and that is the way condition variables are intended to be used. Note the example uses a while loop to check the condition variable before entering the wait and then again after waking and before unlocking the mutex. If the condition isn't true after waking the CV should go back into the wait. Google search for "condition variable spurious wakeup".Sent from my phone
-------- Original message --------From: Markus Forrer via Pthreads-win32 <> Date: 31/3/21  2:37 am  (GMT+10:00) To: Ger Hobbelt <> Cc: Subject: Aw: Re: Problems with conditions Thank you for your answer.The main problem was the line:pthread_mutexattr_settype(&_mutexAttribute, PTHREAD_MUTEX_ERRORCHECK); After changing to PTHREAD_MUTEX_DEFAULT it works.

  reply	other threads:[~2021-03-31  1:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:19 markus.forrer
2021-03-30  7:15 ` Ger Hobbelt
2021-03-30 15:37   ` Aw: " markus.forrer
2021-03-31  1:30     ` ross.johnson [this message]
2021-03-31  4:43       ` Markus Forrer

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:

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

  git send-email \
    --in-reply-to='96626b$' \ \ \ \ \

* 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).