All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrzej K. Haczewski" <ahaczewski@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] MSVC: port pthread code to native Windows threads
Date: Wed, 4 Nov 2009 14:47:09 +0100	[thread overview]
Message-ID: <16cee31f0911040547m69e5b9cbi30e20d2a7790bd6f@mail.gmail.com> (raw)
In-Reply-To: <4AF175E8.7020400@viscovery.net>

2009/11/4 Johannes Sixt <j.sixt@viscovery.net>:
> Please do not cull Cc list when you resend a patch, if possible.

Ok, will do. I was sending patch using git send-email and I just
forgot to copy Cc there. Still trying to BTW is there a way to
"reformat-patch" with new amended commit and then "resend-email"?

> After staring some time on the code, I have convinced myself that the
> pthread_cond_wait and pthread_cond_signal implementation will work *in our
> usage scenario* that has these preconditions:

But it is not impossible with that implementation. I based this
implementation on ACE (Adaptive Communication Environment, large C++
library) implementation of the same concepts. All I removed from their
implementation is cond_broadcast, since it's not used by Git. I'm sure
that ACE does the best job when it comes to threading primitives.

On resubmit I'll give more credit to ACE.

> - pthread_cond_signal is called while the mutex is held.

AFAIK that is a requirement for condition variable to be signaled
while holding the same mutex that other threads cond_wait on. I just
don't check that it is true, because Git is locking mutex.

> - We retest the condition after pthread_cond_wait returns.
>
> These conditions should be attached in BIG BOLD letters to this
> implementation; particularly, the last one.

That's also a known requirement for working with cond vars. Here's
excerpt from pthread_cond_wait man page:
When using condition variables there is always a boolean predicate
involving shared variables associated with each condition wait that is
true if the thread should proceed. Spurious wakeups from the
pthread_cond_wait() or pthread_cond_timedwait() functions may occur.
Since the return from pthread_cond_wait() or pthread_cond_timedwait()
does not imply anything about the value of this predicate, the
predicate should be re-evaluated upon such return.

> The subject is a bit misleading, IMHO. You are not porting the
> (p)threading code, but you are adding pthread_* function wrappers for Windows.
>
> Your patch adds whitespace-at-eol. Please use git show --check to see where.
>
> Please drop words from the commit message that do not make sense once this
> commit is in git's history. Look at existing commit messages to get a
> feeling for the style. Do write about "why" (motivation), "how" (design
> choices) and "how not" (dead ends that you tried).
>

Ok, thanks for pointing that out.

> I think it would be OK to drop '= PTHREAD_{MUTEX,COND}_INITIALIZER' and
> use *_init function calls without the #ifdef. Likewise for *_destroy.

Actually it won't save us many #ifdefs. There's one #ifdef for
initialization that could be saved, but then comes #ifdef for cleanup:
#if defined(THREADED_DELTA_SEARCH) && defined(_WIN32)

What you propose will remove one #ifdef _WIN32 for initialization, but
the cleanup will look almost the same:
#ifdef THREADED_DELTA_SEARCH

>
> -- Hannes
>

Thanks for awesome review, I'll fix all those returns and whitespaces
and resubmit.

--
Andrzej

  reply	other threads:[~2009-11-04 13:47 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-03 21:30 [PATCH 0/1] Port of pthreads to Windows API threads Andrzej K. Haczewski
2009-11-03 21:30 ` [PATCH 1/1] MSVC: port pthread code to native Windows threads Andrzej K. Haczewski
2009-11-03 23:38   ` Johannes Schindelin
2009-11-04  2:34     ` Joshua Jensen
2009-11-04  7:44       ` Andrzej K. Haczewski
2009-11-04  8:24         ` Johannes Sixt
2009-11-04 11:02       ` Johannes Schindelin
2009-11-04  8:17     ` Andrzej K. Haczewski
2009-11-04  8:15   ` Johannes Sixt
2009-11-04  8:48     ` Michael Wookey
2009-11-04 10:53     ` Andrzej K. Haczewski
2009-11-04 10:37 ` [PATCH] " Andrzej K. Haczewski
2009-11-04 10:50   ` Erik Faye-Lund
2009-11-04 10:56     ` Andrzej K. Haczewski
2009-11-04 11:14     ` Paolo Bonzini
2009-11-04 11:23   ` Paolo Bonzini
2009-11-04 12:39   ` Johannes Sixt
2009-11-04 13:47     ` Andrzej K. Haczewski [this message]
2009-11-04 14:34       ` Johannes Sixt
2009-11-04 14:50         ` Andrzej K. Haczewski
2009-11-04 20:43           ` Daniel Barkalow
2009-11-04 21:17             ` Nicolas Pitre
2009-11-04 22:22               ` Daniel Barkalow
2009-11-05  0:27                 ` Nicolas Pitre
2009-11-05 13:48       ` Dmitry Potapov
2009-11-04 14:14     ` Andrzej K. Haczewski
2009-11-04 14:19       ` Erik Faye-Lund
2009-11-04 14:04   ` Johannes Schindelin
2009-11-04 15:55   ` [PATCH] MSVC: Windows-native implementation for subset of Pthreads API Andrzej K. Haczewski
2009-11-04 18:10     ` Nicolas Pitre
2009-11-04 21:16       ` Andrzej K. Haczewski
2009-11-04 21:32         ` [PATCH] pack-objects: move thread autodetection closer to relevant code Nicolas Pitre
2009-11-06  7:20           ` Junio C Hamano
2009-11-04 21:41         ` [PATCH] MSVC: Windows-native implementation for subset of Pthreads API Erik Faye-Lund
2009-11-04 22:50           ` Andrzej K. Haczewski
2009-11-05  2:47             ` Nicolas Pitre
2009-11-05  9:00               ` Andrzej K. Haczewski
2009-11-05  9:41                 ` Erik Faye-Lund
2009-11-05 10:18                 ` Andrzej K. Haczewski
2009-11-05 12:27                   ` Johannes Sixt
2009-11-05 12:53                     ` Andrzej K. Haczewski
2009-11-05 19:25                 ` Nicolas Pitre
2009-11-05 20:38                   ` Andrzej K. Haczewski
2009-11-05 22:15                     ` Nicolas Pitre
2009-11-04 21:52         ` Nicolas Pitre
2009-11-04 23:47         ` Andrzej K. Haczewski
2009-11-04 23:57           ` Andrzej K. Haczewski
2009-11-05  0:22             ` Nicolas Pitre
2009-11-05  8:51               ` Andrzej K. Haczewski
2009-11-05 19:22                 ` Nicolas Pitre
2009-11-05  2:10             ` Nicolas Pitre
2009-11-05  8:45               ` Andrzej K. Haczewski
2009-11-05 19:17                 ` Nicolas Pitre
2009-11-05  7:33             ` Johannes Sixt
2009-11-04 23:58       ` Junio C Hamano
2009-11-05 16:45 ` Andrzej K. Haczewski
2009-11-05 17:31   ` Johannes Sixt
2009-11-05 19:39   ` Nicolas Pitre
2009-11-05 20:09     ` Andrzej K. Haczewski
2009-11-05 20:36       ` Nicolas Pitre
2009-11-06  8:10 ` Andrzej K. Haczewski
2009-11-06  8:25   ` Johannes Sixt

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=16cee31f0911040547m69e5b9cbi30e20d2a7790bd6f@mail.gmail.com \
    --to=ahaczewski@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    /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.