b*********a 发帖数: 28 | 1 Thank you all very much for providing me the
useful information, I almost make it clear
for 2 different programs to share data.
however, I still have one question. When Program A
and B want to share the memory, they need a common
KEY to be passed to the shmget, shmat, shmdt, shmctrl.
What is this KEY? Where to get it? Can I just use
any integer number provided that A and B use the same?
Anybody experienced this please kindly give more information
or any clue.
Thank you all! | c*m 发帖数: 9 | 2
key is used for that u can get unique mem(semphora, msg queue,....) ID for the
system. In general, you can input an integer from the stdin. Before using the
share mem, make sure u called shmget(...), get the ID.
【在 b*********a 的大作中提到】 : Thank you all very much for providing me the : useful information, I almost make it clear : for 2 different programs to share data. : however, I still have one question. When Program A : and B want to share the memory, they need a common : KEY to be passed to the shmget, shmat, shmdt, shmctrl. : What is this KEY? Where to get it? Can I just use : any integer number provided that A and B use the same? : Anybody experienced this please kindly give more information : or any clue.
| s*****g 发帖数: 219 | 3 Moreover, you need to know the Key has a time out;
After you terminate your program, you can not reuse
the same key in following several minutes. You have
to change your source code to use another KEY.
It is not mentioned in books, but makes you mad in
debugging.
【在 c*m 的大作中提到】 : : key is used for that u can get unique mem(semphora, msg queue,....) ID for the : system. In general, you can input an integer from the stdin. Before using the : share mem, make sure u called shmget(...), get the ID.
|
|