[lkml]   [2003]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: shmat problem
"Dirk Bull" <> 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_));

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.027 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site