PTHREAD_PROCESS_SHARED not implemented (was PTHREAD_MUTEX_SHARED on Cygwin)

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Sat Jan 9 22:54:24 GMT 2021


On 2021-01-09 15:16, Brian Inglis wrote:
> On 2021-01-09 12:58, Brian Inglis wrote:
>> 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.
> 
> It looks like there was nothing on this between implementation circa 2002 and:
> 
> https://sourceware.org/pipermail/cygwin/2019-February/240178.html
> 
> Presumably your goal is to support or disqualify gfortran coarrays:
> 
> https://gcc.gnu.org/pipermail/fortran/2021-January/055542.html
> 
> For more about Windows limitations and alternatives see:
> 
> https://www.boost.org/doc/libs/1_75_0/doc/html/interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.sharedmemory.emulation 
> 
> 
> and the internal page link target:
> 
> https://www.boost.org/doc/libs/1_75_0/doc/html/interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.sharedmemory.windows_shared_memory 

Bit more discussion where Dave Korn suggests using Sys V IPC semaphores instead:

https://cygwin.com/pipermail/cygwin/2006-September/150304.html

which I believe requires running the cygserver daemon as a Windows service, 
using cygrunsrv as a Windows elevated admin process, possibly in a scheduled 
task at startup or logon.

-- 
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.]


More information about the Cygwin mailing list