lkml.org 
[lkml]   [2003]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: shmat problem
    From
    Date
    "Dirk Bull" <dirkbull102@hotmail.com> writes:

    > Doug, thanks for the reply. I've set SHM_RND in the call and used
    > "__attribute__ ((aligned(4096)))" during the the declaration of
    > variable global01_
    > (as shown below) such that it is aligned on a page boundary. I'm
    > porting code that was
    > written for a Unix system to Linux and the example shown below is how
    > the code is
    > implemented on Unix.

    Hmmm, I may be ignorant, but I don't see how the below could work.
    You're asking for the kernel to map your shared memory in the middle
    of an already-mapped area (the bss segment). I'm actually surprised
    it works on any Unix.

    If you can point out a clear violation of the POSIX spec, someone may
    be willing to change it, but it's not clear to me that you're
    guaranteed to be able to map a shared memory area inside your existing
    data segment.

    > union {
    > long IN[2048];
    > } global01_ __attribute__ ((aligned(4096)));

    [...]

    > if ( (shmptr = shmat(shmid, &global01_, SHM_RND)) == (void *) -1)
    > printf("shmat error: %d %s\n",errno, strerror(errno));
    > else
    > printf("shared memory attached from %x to %x\n",
    > shmptr, shmptr+sizeof(global01_));

    -Doug
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:32    [W:0.034 / U:4.748 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site