由买买提看人间百态

topics

全部话题 - 话题: shmat
(共0页)
z*l
发帖数: 763
1
来自主题: WHU版 - [转载] 多进程编程2
【 以下文字转载自 Unix 讨论区 】
【 原文由 zhl 所发表 】
本令只能由有效UID等于shm_perm.cuid或shm_perm.uid的
进程或有效UID有合适权限的进程操作.
返回值:若调用成功则返回0,否则返回-1.
例子:本例包括上述所有共享内存操作系统调用:
#include
#include
#include
#define SHMKEY 74
#define K 1024
int shmid;
cleanup()
{
shmctl(shmid,IPC_RMID,0);
exit(0);
}
main()
{
int *pint;
char *addr1,*addr2;
extern char *shmat();
extern cleanup();
for (i=0;i<20;i++)
signal(i,cleanup);
shmid=shmget(SHMKEY,128*K,0777|IPC_CREAT);
addr1=shmat(shmid,0,0);
addr2=shmat(shm
c******n
发帖数: 4965
2
来自主题: Unix版 - [转载] two programming questions
【 以下文字转载自 Linux 讨论区 】
【 原文由 creation 所发表 】
in semaphore, if I want to use the semaphore between processes
I have to put the semaphore in shared memory
i.e.
for sem_init(sem_t *sem,.....)
the #sem# has to be in shared mem
but I can't tell malloc to allocate a #sem# in
a particular region,
neither can I tell shmat() to attach to an existing
real memory region (i.e.
sem=malloc()
shmat(shm_id, sem,...)
)
so how can i do this?
(2) in open('filename', O_XXXX, S_IRUSR) , the S_IRUSR flag,
where does
b*********a
发帖数: 28
3
来自主题: Unix版 - Key in Shared Memory
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!
z***h
发帖数: 3
4
I try to install Firebird 2.7 on Solaris machine, SunOS 5.7.
Compilation is successful, but the problem is only 6 shared
memory can be attached to the process. For instance, I can
only call "shmat()" 6 times, then the next call will cause
an "too many files error".
Is there any settings related to how many segments we can
attach to a process?
//bow a thousand times!!!!
(共0页)