When I looked through the man pages of shmat
. It is described as the primitive function of the API is to attach the memory segment associated wih shmid
it to the calling process' address space .
The questions I have are the following.
Use it as char *ptr=shmat(seg_id,NULL,0);
It attaches the created segment id by function shmget()
with the process which contains this above code.
seg_id
is the segment id of newly created segment
NULL
means the Operating System will take care of the starting address of the segment on user's behalf
0
is flag for read/write
both
Whenever a process attaches to shared memory then it must be detached so that another process can access it by attaching to that segment (if the locking mechanism of resources is present.)
to detach : shmdt(ptr);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With