git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] MSVC: port pthread code to native Windows threads

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Nov 4, 2009, 14:34 UTC
Message-ID
<4AF190F1.3020607@viscovery.net>
In-Reply-To
<16cee31f0911040547m69e5b9cbi30e20d2a7790bd6f@mail.gmail.com>
Andrzej K. Haczewski schrieb:
Show 6 quoted lines
> 2009/11/4 Johannes Sixt <j.sixt@viscovery.net>:
>> 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.
Read again what I wrote: We are in agreement.
> On resubmit I'll give more credit to ACE.

Perhaps also a link to the source and, even better, to a discussion of the implementation.

Show 5 quoted lines
>> - 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.
It is not a requirement, but, yes, we do hold the mutex.
Show 6 quoted lines
>> - 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.
Indeed.
Show 10 quoted lines
>> 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

You are right. But #ifdef THREADED_DELTA_SEARCH is about a "generic" property of the code and is already used elsewhere in the file, whereas #ifdef WIN32 would be new and is is about platform differences.

Anyway, we would have to see what Junio says about the new function calls, because he's usually quite anal when it comes to added code vs. static initialization. ;)

-- Hannes
Previous: Andrzej K. HaczewskiNext: Andrzej K. Haczewski
Message 19 of 62 in “Port of pthreads to Windows API threads”
  1. 0/1 Port of pthreads to Windows API threadsAndrzej K. Haczewski, Nov 3, 2009
  2. 1/1 MSVC: port pthread code to native Windows threadsAndrzej K. Haczewski, Nov 3, 2009
  3. Johannes SchindelinNov 3, 2009
  4. Joshua JensenNov 4, 2009
  5. Andrzej K. HaczewskiNov 4, 2009
  6. Johannes SixtNov 4, 2009
  7. Johannes SchindelinNov 4, 2009
  8. Andrzej K. HaczewskiNov 4, 2009
  9. Johannes SixtNov 4, 2009
  10. Michael WookeyNov 4, 2009
  11. Andrzej K. HaczewskiNov 4, 2009
  12. MSVC: port pthread code to native Windows threadsAndrzej K. Haczewski, Nov 4, 2009
  13. Erik Faye-LundNov 4, 2009
  14. Andrzej K. HaczewskiNov 4, 2009
  15. Paolo BonziniNov 4, 2009
  16. Paolo BonziniNov 4, 2009
  17. Johannes SixtNov 4, 2009
  18. Andrzej K. HaczewskiNov 4, 2009
  19. Johannes SixtNov 4, 2009
  20. Andrzej K. HaczewskiNov 4, 2009
  21. Daniel BarkalowNov 4, 2009
  22. Nicolas PitreNov 4, 2009
  23. Daniel BarkalowNov 4, 2009
  24. Nicolas PitreNov 5, 2009
  25. Dmitry PotapovNov 5, 2009
  26. Andrzej K. HaczewskiNov 4, 2009
  27. Erik Faye-LundNov 4, 2009
  28. Johannes SchindelinNov 4, 2009
  29. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 4, 2009
  30. Nicolas PitreNov 4, 2009
  31. Andrzej K. HaczewskiNov 4, 2009
  32. pack-objects: move thread autodetection closer to relevant codeNicolas Pitre, Nov 4, 2009
  33. Junio C HamanoNov 6, 2009
  34. Erik Faye-LundNov 4, 2009
  35. Andrzej K. HaczewskiNov 4, 2009
  36. Nicolas PitreNov 5, 2009
  37. Andrzej K. HaczewskiNov 5, 2009
  38. Erik Faye-LundNov 5, 2009
  39. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 5, 2009
  40. Johannes SixtNov 5, 2009
  41. Andrzej K. HaczewskiNov 5, 2009
  42. Nicolas PitreNov 5, 2009
  43. Andrzej K. HaczewskiNov 5, 2009
  44. Nicolas PitreNov 5, 2009
  45. Nicolas PitreNov 4, 2009
  46. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 4, 2009
  47. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 4, 2009
  48. Nicolas PitreNov 5, 2009
  49. Andrzej K. HaczewskiNov 5, 2009
  50. Nicolas PitreNov 5, 2009
  51. Nicolas PitreNov 5, 2009
  52. Andrzej K. HaczewskiNov 5, 2009
  53. Nicolas PitreNov 5, 2009
  54. Johannes SixtNov 5, 2009
  55. Junio C HamanoNov 4, 2009
  56. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 5, 2009
  57. Johannes SixtNov 5, 2009
  58. Nicolas PitreNov 5, 2009
  59. Andrzej K. HaczewskiNov 5, 2009
  60. Nicolas PitreNov 5, 2009
  61. MSVC: Windows-native implementation for subset of Pthreads APIAndrzej K. Haczewski, Nov 6, 2009
  62. Johannes SixtNov 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.