This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: problem with mmap and fork()
- From: Houder <houder at xs4all dot nl>
- To: cygwin at cygwin dot com
- Date: Mon, 25 Feb 2019 08:39:14 +0100
- Subject: Re: problem with mmap and fork()
- References: <CAAoGPJzdYcCDB=J4ZdfDq1xwLYvZBmT1rC937xHjMd8vseZ-=A@mail.gmail.com> <CAJ1FpuNG7a2nrK0A90VKuT9dAe5pf+aRbJzr65=cgQMxQ8rsuQ@mail.gmail.com>
- Reply-to: cygwin at cygwin dot com
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