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?
You use
shmat()to alias the shared memory you created to any arbitrary page-aligned range in your address-spaceSo this isn't taking some memory you already have and publishing it; its taking some new shared memory, you then copy what you want to publish across, then use
shmatto alias it to where you had what you wanted to publish - this has the same effect.