Page 1 of 1

3. Develop a program to do the follows. (30pts) a) Access a shared memory segemnt using key = ftok("/tmp", 'z'); b) Atta

Posted: Fri May 20, 2022 3:06 pm
by answerhappygod
3. Develop a program to do the follows. (30pts) a) Access a
shared memory segemnt using key = ftok("/tmp", 'z'); b) Attach the
shared memory segment. c) Output the content of the shared memory
segment. d) Use IPC_STAT to output the value of shm_nattch, No. of
current attaches. See the strut below.
e) Detach the shared memory segment. */ struct shmid_ds { struct
ipc_perm shm_perm; /* operation perms */ int shm_segsz; /* size of
segment (bytes) */ time_t shm_atime; /* last attach time */ time_t
shm_dtime; /* last detach time */ time_t shm_ctime; /* last change
time */ unsigned short shm_cpid; /* pid of creator */ unsigned
short shm_lpid; /* pid of last operator */ short shm_nattch; /* no.
of current attaches */ /* the following are private */ unsigned
short shm_npages; /* size of segment (pages) */ unsigned long
*shm_pages; /*array of ptrs to frames -> SHMMAX*/ struct
vm_area_struct *attaches; /* descriptors for attaches */ };