X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:message-id:from:reply-to:to:subject :references:in-reply-to:content-type; q=dns; s=default; b=dYxB+T BNtcLHyr2metAE5ty6llttvDx1LHz9RlSEF22kiz2fbHmv6BdNf4NQd+wrVokIAY lTUApOrYwwKPJ4ROFlcHansMi3s3EPrtSdAtkSMkPvfhGYXHkxTJxGceum1Hzls7 bYmDrWKwaXUIyt8VrRI79RhKPPh+rouAIRCS8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:message-id:from:reply-to:to:subject :references:in-reply-to:content-type; s=default; bh=1un+2QDz/uGU ax1aKH1tevU4zOg=; b=Qu1eJmXeRoQ40y6pSzDE9BS+LSczr2itHjis+/9AVlFf kDvnocaV/jIbgY+OY6VpW+AMWVWbTeS/aNM+B+o+Y0e0w0JTZ8okTkFWuX4BqCcS 5dUisBUJFdMs40ebcZfAF2kwlhn5c3D4of2Mb+p3bD47foKi9FLM/KkGYJjon7Q= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:smtp, logically, unlocked, H*F:D*nl X-HELO: lb1-smtp-cloud7.xs4all.net Date: Mon, 25 Feb 2019 08:39:14 +0100 Message-ID: <59436234de373d19e5918fd05cc1e0b4@smtp-cloud7.xs4all.net> From: Houder Reply-To: cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: Re: problem with mmap and fork() References: In-Reply-to: Content-Type: text/plain; charset=UTF-8; format=fixed User-Agent: mua.awk 0.99 On Sat, 23 Feb 2019 05:54:18, Doug Henderson wrote: > On Fri, 22 Feb 2019 at 17:01, Glyn Gowing <> wrote: > > I have a program (attached) that works correctly on my mac but does > > not work with Cygwin on Windows 10. I'm running the latest version of [snip] > On further analysis, the call to > > pthread_mutexattr_setpshared(attr, PTHREAD_PROCESS_SHARED); > is failing. The error is EINVAL (22) Invalid argument. > > This suggests that pthread mutexes cannot be shared between processes > by using shared memory in cygwin. I have not attempted to determine if > this is working as expected, or if this is a bug, or a limitation in > the Windows environment. For the record, the output on Linux (FC28): @@ ./Dsmtest2 (Doug's version of the original smtest2.c) 1551022585 - both : attr, lock, lock->next: 0x7f4ec2ceb000 0x7f4ec2cec000 0x7f4ec2cec000 1551022585 - Parent: acquiring lock (0x7f4ec2cec000) 1551022585 - Parent: acquired lock (0x7f4ec2cec000) - Before sleeping 10 seconds. 1551022585 - Child : checking lock (0x7f4ec2cec000) - Before sleeping 5 seconds. 1551022590 - Child : acquiring lock (0x7f4ec2cec000) - After sleeping 5 seconds. 1551022595 - Parent: unlocking lock (0x7f4ec2cec000) - After sleeping 10 seconds. 1551022595 - Parent: unlocked lock (0x7f4ec2cec000) - Before sleeping 5 seconds to let child catch up. 1551022595 - Child : acquired lock (0x7f4ec2cec000) - Before sleeping 3 seconds. 1551022598 - Child : unlocking lock (0x7f4ec2cec000) - After sleeping 3 seconds. 1551022598 - Child : unlocked lock (0x7f4ec2cec000). 1551022600 - - After sleeping 5 seconds to let child catch up. @@ ... as I understand it, this is between a parent thread and a child thread, after fork(), -- and only these two! -- using mutexes in shared memory, that is, shared memory between the two processes (parent and child) ... Logically, I would say, the same as 2 threads in one process ... (and yes, in general, all threads are "dead" after fork(), except for the thread that is the child of the calling thread). Henri -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple