Hi All,
This is my first post - and I am just beginning C so your help is greatly appreciated.
I'm trying to understand the size_t param for shmget() as well as the limits of shared memory in general. I'm on Linux for now, but want this to be cross platform.
When creating a shared memory segment I create the size based on filesize (character length) + a buffer + 1 (for an extra \0 since for now I am storing strings).
When I later go to read a shared memory segment I am confused as to what is happening. I have a ton of questions so I hope I am asking them correctly.
shmget(key,filesize, IPC_CREAT | 0555)
If I am retrieving a shared memory segment how would I know filesize ahead of time? Would I need to?
When I get the stat from shmctrl it is a different size than PAGE_SIZE (which I thought it rounded up to) and from the size I allocated. So what is size of shared memory segment really about?
I've ready quite a bit on the web and some of the Linux man page. But I don't understand the size allocations and limitations of shared memory segments.
PS
Should I remove IPC_CREAT if I want it to fail if it doesn't exist?
This is my first post - and I am just beginning C so your help is greatly appreciated.
I'm trying to understand the size_t param for shmget() as well as the limits of shared memory in general. I'm on Linux for now, but want this to be cross platform.
When creating a shared memory segment I create the size based on filesize (character length) + a buffer + 1 (for an extra \0 since for now I am storing strings).
When I later go to read a shared memory segment I am confused as to what is happening. I have a ton of questions so I hope I am asking them correctly.
shmget(key,filesize, IPC_CREAT | 0555)
If I am retrieving a shared memory segment how would I know filesize ahead of time? Would I need to?
When I get the stat from shmctrl it is a different size than PAGE_SIZE (which I thought it rounded up to) and from the size I allocated. So what is size of shared memory segment really about?
I've ready quite a bit on the web and some of the Linux man page. But I don't understand the size allocations and limitations of shared memory segments.
PS
Should I remove IPC_CREAT if I want it to fail if it doesn't exist?