> 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/