In c you can do
shmid = shmget(SHMEM_KEY, sizeof(int*) * n , SHEMEM_MODE | IPC_CREAT);
int* shmem = shmat(shmid, NULL, 0);
to assign first given free memory space as a shared memory.
Is there any way to assigne current memory space as a shared memory?
First I would advise not to use the oldish
shmget
interfaces but the more modern POSIX interfacesshm_open
andmmap
(if you have them, you didn't specify your system)Then the
mmap
allows you to propose an address in your address space where you'd like to have the segmentthis is not exactly what you are asking for, but the closest you can get, I think