Subject: Re: PTHREAD_MUTEX_SHARED on Cygwin
From: Brian Inglis <[email-masked]>
To: [email-masked]
Date: Sat, 9 Jan 2021 12:58:11 -0700
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On 2021-01-09 11:23, Thomas Koenig via Cygwin wrote:
> there is a branch of gfortran for implementing coarrays based on a
> shared memory implementation instead of MPI, the devel_coarray/native
> branch.
> 
> I tried it out on Cygwin, but it doesn't work there (hangs on the
> first sync).
> 
> The branch uses pthread mutexes and condition variables
> with PTHREAD_PROCESS_SHARED for synchronization between processes.
> 
> I also ran the attached test program, which gave the output
> 
> pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)failed: No error
> 
> 
> Is it correct that PTHREAD_PROCESS_SHARED is not supported on
> Cygwin?  Is it supported for condition variables, or is the fact
> that it is reported as working an oversight?

The function is supported but that parameter is not implemented or tested and 
returns EINVAL:

https://sourceware.org/git?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/thread.cc;hb=HEAD#l16

https://sourceware.org/git?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/thread.cc;hb=HEAD#l1889

> If PTHREAD_PROCESS_SHARED does not work, are there known workarounds?

If you have the ability and time to work on this, one of the Cygwin 
developers/maintainers may be able to assist.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple