| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 48A6238708D3 |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1610216624; | |
| bh=C+49JTNRSm1VUw0wnYUTyeT4GvswnOMUuLTThgdYfTo=; | |
| h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: | |
| List-Help:List-Subscribe:From:Reply-To:From; | |
| b=V7burmxrdzNTF4EGWSRYGUoZue5KY47DHzBKHdqjvKiQVF33JtGQUOz86MXr0H2Ld | |
| cmtYRXRKLVBQsWqRKZrm/C/ao28IaWzv4NF9bGvK6CcLANf2KvqBOImMAHtf42suCM | |
| DvqFP4nSUmXgTmBIi5b/D6fWszcnQbe948An2PaY= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.3.2 sourceware.org 0718138708C0 |
| To: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
| Subject: | PTHREAD_MUTEX_SHARED on Cygwin |
| Message-ID: | <657c8576-2715-8c80-a59a-23453306230f@netcologne.de> |
| Date: | Sat, 9 Jan 2021 19:23:39 +0100 |
| User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 |
| Thunderbird/78.6.0 | |
| MIME-Version: | 1.0 |
| X-Spam-Status: | No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, |
| DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, | |
| SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 | |
| X-Spam-Checker-Version: | SpamAssassin 3.4.2 (2018-09-13) on |
| server2.sourceware.org | |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.29 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | Thomas Koenig via Cygwin <cygwin AT cygwin DOT com> |
| Reply-To: | Thomas Koenig <tkoenig AT netcologne DOT de> |
| Sender: | "Cygwin" <cygwin-bounces AT cygwin DOT com> |
This is a multi-part message in MIME format.
--------------EAE2AEE4CB4327D20C84C5FF
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
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?
If PTHREAD_PROCESS_SHARED does not work, are there known workarounds?
Best regards
Thomas
--------------EAE2AEE4CB4327D20C84C5FF
Content-Type: text/x-csrc; charset=UTF-8;
name="s.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="s.c"
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#define ERR_CHK(x) \
do { \
if (x) { \
perror(#x "failed"); \
exit(1); \
} \
} while (0)
int
main(int argc, char **argv) {
pthread_condattr_t cattr;
pthread_mutexattr_t mattr;
pthread_mutex_t *m;
pthread_cond_t *c;
void *mem;
ERR_CHK((mem = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == MAP_FAILED);
m = mem;
c = mem + 0x800;
ERR_CHK(pthread_mutexattr_init(&mattr));
ERR_CHK(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED));
ERR_CHK(pthread_mutex_init(m, &mattr));
ERR_CHK(pthread_mutexattr_destroy(&mattr));
ERR_CHK(pthread_condattr_init(&cattr));
ERR_CHK(pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED));
ERR_CHK(pthread_cond_init(c, &cattr));
ERR_CHK(pthread_condattr_destroy(&cattr));
printf("Success\n");
return 0;
}
--------------EAE2AEE4CB4327D20C84C5FF
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--
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
--------------EAE2AEE4CB4327D20C84C5FF--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |