problem with mmap and fork()
Houder
houder@xs4all.nl
Mon Feb 25 10:03:00 GMT 2019
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
More information about the Cygwin
mailing list