From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49628 invoked by alias); 13 Apr 2015 11:00:18 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 49608 invoked by uid 89); 13 Apr 2015 11:00:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.4 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nm41-vm8.bullet.mail.bf1.yahoo.com Received: from nm41-vm8.bullet.mail.bf1.yahoo.com (HELO nm41-vm8.bullet.mail.bf1.yahoo.com) (216.109.114.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 13 Apr 2015 11:00:13 +0000 Received: from [98.139.215.142] by nm41.bullet.mail.bf1.yahoo.com with NNFMP; 13 Apr 2015 11:00:10 -0000 Received: from [98.139.212.219] by tm13.bullet.mail.bf1.yahoo.com with NNFMP; 13 Apr 2015 11:00:10 -0000 Received: from [127.0.0.1] by omp1028.mail.bf1.yahoo.com with NNFMP; 13 Apr 2015 11:00:10 -0000 Received: by 76.13.26.65; Mon, 13 Apr 2015 11:00:10 +0000 Date: Mon, 13 Apr 2015 11:00:00 -0000 From: Christoph Weise Reply-To: Christoph Weise To: "cygwin@cygwin.com" Message-ID: <1870355684.2072453.1428922807636.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <1999567694.2259208.1428493743005.JavaMail.yahoo@mail.yahoo.com> References: <1999567694.2259208.1428493743005.JavaMail.yahoo@mail.yahoo.com> Subject: Re: Shared memory handling for mixed C/FORTRAN program MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-04/txt/msg00266.txt.bz2 > 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. Yes, you're right. I tried a workaround that uses a second shm section to pass between executables either the size or more simply the shm ID of the main shm section. Either way this circumvented the problem. However with this solution there is an odd change in the base address of the shm section between calls from the routine that creates the section to the executables that use it. I may be using the shm library inappropriately but my guess is that the OS/cygwin is doing something in the background (making a copy of the data?). Just for reference here's sample output: $ $ ./test1.exe storing in address 7fea0000 (7fea0000 + 0 floats): 0.000000 ................. storing in address 7fea0fec (7fea0000 + 1019 floats): 1019.000000 storing in address 7fea0ff0 (7fea0000 + 1020 floats): 1020.000000 storing in address 7fea0ff4 (7fea0000 + 1021 floats): 1021.000000 storing in address 7fea0ff8 (7fea0000 + 1022 floats): 1022.000000 storing in address 7fea0ffc (7fea0000 + 1023 floats): 1023.000000 -------------------------------------------- Detached from the shared memory section. Attached at second address 7fea0000. Message Queues: T ID KEY MODE OWNER GROUP Shared Memory: T ID KEY MODE OWNER GROUP m 1179648 3989570537 --rw-rw-rw- John John m 131073 3989505001 --rw-rw-rw- John John Semaphores: T ID KEY MODE OWNER GROUP -------------IN RUNME/FINDSHM---------------- Mapping the shared memory section ... This is the key: -305396759. size of section should be 4096. Got this far (shmid : 131073). Size of section: 4096. Attached at address 7fe90000. -------------------------------------------- Checking memory pointers pptr: 7fe90000 cptr: 7fe90200 cptr-pptr: 512 -------------------------------------------- Check writing into the buffer at addresses starting at 7fe90000 + 4076 bytes (buffer size: 4096 bytes) storing in address 7fe90000 (7fe90000 + 0 floats): 0.000000 ................. content of address 7fe90fec (7fe90000 + 1019 floats): 1019.000000 storing in address 7fe90fec (7fe90000 + 1019 floats): 2038.000000 content of address 7fe90ff0 (7fe90000 + 1020 floats): 1020.000000 storing in address 7fe90ff0 (7fe90000 + 1020 floats): 2040.000000 content of address 7fe90ff4 (7fe90000 + 1021 floats): 1021.000000 storing in address 7fe90ff4 (7fe90000 + 1021 floats): 2042.000000 content of address 7fe90ff8 (7fe90000 + 1022 floats): 1022.000000 storing in address 7fe90ff8 (7fe90000 + 1022 floats): 2044.000000 content of address 7fe90ffc (7fe90000 + 1023 floats): 1023.000000 storing in address 7fe90ffc (7fe90000 + 1023 floats): 2046.000000 >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. That did the trick. With the new cygwin1 DLL I don't need to pass shm section information between executables and the overall behavior is consistent with that on Linux. Thank you for your help! I am very happy this works now on cygwin. -- 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