From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Shared memory handling for mixed C/FORTRAN program
Date: Sun, 12 Apr 2015 12:18:00 -0000 [thread overview]
Message-ID: <20150412121805.GQ7343@calimero.vinschen.de> (raw)
In-Reply-To: <20150412112325.GP7343@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]
On Apr 12 13:23, Corinna Vinschen wrote:
> On Apr 11 20:25, Christoph Weise wrote:
> > Please see below, I provide minimal C code for three separate
> > executables, one creates the shm section, another finds it, the third
> > removes it. I include also a bash test script that executes the
> > routines in order.
>
> Thanks,
>
> > Please beware as I removed some checks to reduce
> > the length of the code, but it should run ok. The PAGESIZE parameter
> > is hardcoded (here 512 bytes). The desired shared mem section size is
> > set interactively as input to makeshm, or automatically with the bash
> > script.
>
> Ok, but there are bugs in the code which result in GCC warnings. I
> don't know which of them are part of your original code, but they are
> really a problem.
>
> if ((int) -1 == p)
>
> Don't check a pointer against an int value. It won't work on a 64 bit
> platform. Make that
>
> if ((void *) -1 == p)
>
> For the same reason, don't use %x to printf a pointer. Use %tx.
>
> > I can write to the shm section with the second routine when the requested section <= 4096 bytes. Otherwise it's not happy.
>
> The problem is the call to shmget:
>
> #undef PAGESIZE
> #define PAGESIZE 512
> shmid = shmget(key, PAGESIZE, IPC_ALLOC);
>
> Since you're requesting only 512 bytes, the shared memory segment the
> following shmat call returns is only 4K. The shmget call should request
> as much memory as it needs so that the OS call is called with the right
> view size.
>
> I re-read the POSIX man page for shmget, and it doesn't mention anything
> which would point out that Cygwin's behaviour here is wrong. If anybody
> has more information on this, please share them.
On second thought, adjusting Cygwin's behaviour to Linux here is rather
trivial. I applied a patch to the git repo and uploaded new developer
snapshots (2015-04-12) to https://cygwin.com/snapshots/
You only have to replace the DLL itself, cygserver is not affected by
this patch. Please give it a try.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-04-12 12:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 11:49 Christoph Weise
2015-04-08 15:38 ` Marco Atzeri
2015-04-09 7:58 ` Corinna Vinschen
2015-04-10 22:20 ` Christoph Weise
2015-04-11 10:18 ` Corinna Vinschen
2015-04-11 20:25 ` Christoph Weise
2015-04-12 11:23 ` Corinna Vinschen
2015-04-12 12:18 ` Corinna Vinschen [this message]
2015-04-13 11:00 ` Christoph Weise
2015-04-14 7:39 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150412121805.GQ7343@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).