I was wandering if any of you worked with Shared Memory in Linux except Govtcheez .
I was wandering if any of you worked with Shared Memory in Linux except Govtcheez .
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
I have a little shared memory stuff at hand, although it was written by others, I only maintain it. Its not on Linux either... so not much help, eh?!
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Seems interesting.. So you did it in Windows
You can share your technique here with if not a problem of copy rights.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
I can help with shared memory... what exactly are you looking to know?
starX
www.axisoftime.com
I want to work with a data structure like BTree.
Here I'm going to the specific point. I got problem when I have to know the size of the memory I need before I allocate as shared. But I need such a technique where I don't have to know the size of memory and I can dynametically increase or decrease the size of memory I need to share.
Let know if it's not much clear.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
Just so I know I'm following you, you need to know how much memory you will need initially, but then you want the ability to change it to unspecified amounts during runtime?
starX
www.axisoftime.com
Yeah.. you are correct.
What about if I store the next SHM_BLOCK_ID at the end of the first SHMD_BLOCK ?Code:#define SHM_BLOCK_ID 100 // whatever #define SHM_SIZE (20*1024*1024) #define PERMISSIONS 0666 key = ftok( ".", SHM_BLOCK_ID)
Last edited by zahid; 01-31-2003 at 10:56 PM.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
I must admit I've had to go back and do some reading for this one. If you post your code I'll have a better idea as to what functions you're playing with, but for now my advice would have to be to keep your shared mem size a variable. That way you can create one shared mem block, and when you need to expand its size you can create a new one (using the new size), and basically copy the data from the old block to the new one. Just remember to free up the old block when you're done with it.
I would, however, strongly recommend against using ftok(), try casting the key as a key_t type in your shmget call instead, i.e.:
Hope this helps somewhat.Code:shmget((key_t)3647, sizeof(struct your_custom_header), 0666 | IPC_CREAT);
starX
www.axisoftime.com