avatar
b*a
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!
avatar
c*m
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.

avatar
s*g
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。