SHMCTL

Section: ¸®´ª½º ÇÁ·Î±×·¡¸Ó ¸Þ´º¾ó (2)
Updated: November 28, 1993
Index
Return to Main Contents
 

À̸§

shmctl - °øÀ¯ ¸Þ¸ð¸®¸¦ Á¦¾îÇÑ´Ù.  

»ç¿ë¹ý

#include <sys/ipc.h>

#include <sys/shm.h>

int shmctl(int shmid, int cmd, struct shmid_ds *buf);  

¼³¸í

shmctl() ´Â »ç¿ëÀÚ°¡ °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¿¡ °üÇÑ Á¤º¸¸¦ ¾ò°Å³ª °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®ÀÇ ¼ÒÀ¯ÀÚ, ±×·ì, Çã°¡±ÇµéÀ» ¼³Á¤Çϰųª ¼¼±×¸ÕÆ®¸¦ Æı«ÇÏ´Â°É Çã¿ëÇÑ´Ù. shmid·Î ½Äº°µÇ´Â ¼¼±×¸ÕÆ®¿¡ °üÇÑ Á¤º¸´Â shmid_ds ±¸Á¶Ã¼·Î ¸®ÅϵȴÙ:

struct shmid_ds {
        struct  ipc_perm shm_perm;      /* ÆÛ¹Ì¼Ç */
        int     shm_segsz;              /* ¼¼±×¸ÕÆ®ÀÇ Å©±â(bytes) */
        time_t  shm_atime;              /* ¸¶Áö¸· Á¢±Ù ½Ã°£ */
        time_t  shm_dtime;              /* ¸¶Áö¸· Á¦°Å ½Ã°£ */
        time_t  shm_ctime;              /* ¸¶Áö¸· º¯°æ ½Ã°£ */
        unsigned short  shm_cpid;       /* »ý¼ºÀÚÀÇ pid */
        unsigned short  shm_lpid;       /* ¸¶Áö¸·À¸·Î ÀÛµ¿ÇÑ ÇÁ·Î¼¼½ºÀÇ pid */
        short   shm_nattch;             /* ÇöÀç Á¢±ÙÇÑ ÇÁ·Î¼¼½ºÀÇ ¼ö */
        /* ´ÙÀ½Àº °³º°ÀûÀÌ´Ù */
        unsigned short   shm_npages;  /* ¼¼±×¸ÕÆ®ÀÇ Å©±â(pages) */
        unsigned long   *shm_pages;   
        struct shm_desc *attaches;    /* Á¢±ÙÀ» À§ÇÑ ±â¼úÀÚµé */
};

shm_perm ¸â¹öÀÇ ÇʵåµéÀº ¼³Á¤µÉ¼ö ÀÖ´Ù:

struct ipc_perm
{
  key_t  key;
  ushort uid;   /* ownerÀÇ euid ¿Í egid */
  ushort gid;
  ushort cuid;  /* »ý¼ºÀÚÀÇ euid ¿Í egid */
  ushort cgid;
  ushort mode;  /* Á¢±Ù ¸ðµåÀÇ ÇÏÀ§ 9 bits */
  ushort seq;   /* ¿¬¼Ó ¼ö(sequence number) */
};

´ÙÀ½ cmds°¡ ÀÌ¿ëµÉ¼ö ÀÖ´Ù:

IPC_STAT
°øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¿¡ °üÇÑ Á¤º¸¸¦ ¹öÆÛ buf¿¡ º¹»çÇϱâ À§ÇØ »ç¿ëµÈ´Ù. »ç¿ëÀÚ´Â °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¿¡ readÁ¢±ÙÀ» ÇØ¾ß ÇÑ´Ù.
IPC_SET
shm_permsÇʵåÀÇ uid, gid, or mode ¸â¹öµé¿¡ ´ëÇÑ »ç¿ëÀÚ º¯°æÀ» Àû¿ëÇϱâ À§ÇØ »ç¿ëµÈ´Ù. modeÀÇ ÇÏÀ§ 9ºñÆ®µé¸¸ÀÌ »ç¿ëµÈ´Ù. shm_ctime ¸â¹ö ¶ÇÇÑ °»½ÅµÈ´Ù. »ç¿ëÀÚ´Â ¼ÒÀ¯ÀÚ, »ý¼ºÀÚ, ¶Ç´Â ½´ÆÛ À¯ÀúÀ̾î¾ß ÇÑ´Ù.
IPC_RMID
Æı«µÉ ¼¼±×¸ÕÆ®¸¦ Ç¥½ÃÇϱâ À§ÇØ »ç¿ëµÈ´Ù. ½ÇÁ¦·Î´Â ¸¶Áö¸· ºÐ¸®ÈÄ¿¡ Æı«µÈ´Ù. (Áï, °ü·ÃµÈ shmid_ds ±¸Á¶Ã¼ÀÇ shm_nattch ¸â¹ö°¡ 0À϶§) »ç¿ëÀÚ´Â ¼ÒÀ¯ÀÚ, »ý¼ºÀÚ ¶Ç´Â ½´ÆÛ À¯ÀúÀ̾î¾ß ÇÑ´Ù.

»ç¿ëÀÚ´Â ¼¼±×¸ÕÆ®°¡ °á±¹ Æı« µÇ¾ú´Ù´Â°ÍÀ» º¸ÀåÇØ¾ß ÇÑ´Ù: ±×·¸Áö ¾ÊÀ¸¸é ÆúÆ®°¡ ³­ ÆäÀÌÁöµéÀº ¸Þ¸ð¸®³ª ½º¿Ò¿¡ ³²¾Æ ÀÖÀ» °ÍÀÌ´Ù.

°Ô´Ù°¡, super-user´Â ´ÙÀ½ cmds¿Í °ü·ÃµÈ °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®ÀÇ ½º¿ÒÇÎÀ» ±ÝÁöÇϰųª Çã¿ëÇÒ¼ö ÀÖ´Ù: (Linux only)

SHM_LOCK
°øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®ÀÇ ½º¿ÍÇÎÀ» ¸·´Â´Ù. »ç¿ëÀÚ°¡ ÀÖ¾î¾ß ÇÏ´Â ÆäÀÌÁöµéÀ» Àá±ÝÈÄ¿¡ ¿ä±¸ÇÑ´Ù¸é À§¹ÝÀÌ´Ù.
SHM_UNLOCK
°øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¿¡ ´ëÇÑ ½º¿ÍÇÎÀ» Çã¿ëÇÑ´Ù.

IPC_INFO, SHM_STAT ±×¸®°í SHM_INFO ´Â ÇÒ´çµÈ ÀÚ¿øµé¿¡ °üÇÑ Á¤º¸¸¦ Á¦°øÇÏ´Â ipcs(8) ÀÇ ÀÇÇØ »ç¿ëµÈ´Ù. ¹Ì·¡¿¡, À̰͵éÀº proc ÆÄÀÏ ½Ã½ºÅÛ ÀÎÅÍÆäÀ̽º¸¦ À§Çؼ­ ÇÊ¿äÇÒ¶§ ¼öÁ¤µÇ°Å³ª À̵¿µÉ¼ö ÀÖ´Ù.

 

SYSTEM CALLS

fork()
fork() ÈÄ¿¡ ÀÚ½Ä ÇÁ·Î¼¼½º´Â ¿¬°áµÈ °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®µéÀ» »ó¼ÓÇÑ´Ù.
exec()
exec() ÈÄ¿¡ ¿¬°áµÈ ¸ðµç °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®µéÀº ºÐ¸®µÈ´Ù.(Æı«µÇ´Â°ÍÀÌ ¾Æ´Ï´Ù.)
exit()
exit() ½Ã¿¡ ¿¬°áµÈ ¸ðµç °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®µéÀº ºÐ¸®µÈ´Ù.(Æı«µÇ´Â°ÍÀÌ ¾Æ´Ï´Ù.)

 

¹Ýȯ°ª

¼º°ø½Ã 0ÀÌ ¸®ÅϵǸç, ¿¡·¯½Ã -1ÀÌ ¸®ÅϵȴÙ.  

¿¡·¯

¿¡·¯½Ã, errno ´Â ´ÙÀ½Áß Çϳª·Î ¼³Á¤µÈ´Ù.
EACCES
IPC_STAT°¡ ¿äûµÇ°í shm_perm.modes°¡ msqid ¿¡ ´ëÇÑ Àбâ Á¢±ÙÀÌ Çã¿ëµÇÁö ¾ÊÀ» °æ¿ì ¸®ÅϵȴÙ.
EFAULT
cmd ÀÎÀÚ°¡ IPC_SET ³ª IPC_STAT °ªÀ» °¡Áö°í ÀÖÁö¸¸ buf ¿¡ ÁöÁ¤µÈ ÁÖ¼Ò´Â Á¢±ÙÇÒ¼ö ¾ø´Ù.
EINVAL
shmid°¡ À¯È¿ ½Äº°ÀÚ°¡ ¾Æ´Ï°Å³ª cmd°¡ À¯È¿ÇÑ ¸í·É¾î°¡ ¾Æ´Ï¶ó¸é ¸®ÅϵȴÙ.
EIDRM
shmid°¡ Á¦°ÅµÈ ½Äº°ÀÚ¸¦ °¡¸®Å°°í ÀÖ´Ù¸é ¸®ÅϵȴÙ.
EPERM
IPC_SET³ª IPC_RMID°¡ ½ÃµµµÆ°í »ç¿ëÀÚ°¡ »ý¼ºÀÚ³ª ¼ÒÀ¯ÀÚ ¶Ç´Â ½´ÆÛÀ¯Àú°¡ ¾Æ´Ï°í, »ç¿ëÀÚ°¡ ±×·ìÀ̳ª ±×¿Ü¿¡ ´ëÇÑ Çã°¡±ÇÀ» °¡Áö°í ÀÖÁö ¾Ê´Ù¸é ¸®ÅϵȴÙ.
 

ȣȯ

SVr4, SVID. SVr4´Â Ãß°¡ÀûÀ¸·Î EINVAL, ENOENT, ENOSPC, ENOMEM, EEXIST ¿¡·¯ Á¶°ÇµéÀ» ¹®¼­È­Çß´Ù. SVr4³ª SVID ¸ðµÎ EIDRM ¿¡·¯ Á¶°ÇÀº ¹®¼­È­ ÇÏÁö ¾Ê¾Ò´Ù.  

°ü·Ã Ç׸ñ

shmget(2), shmop(2)  

¿ªÀÚ

Á¤°­ÈÆ <skyeyes@soback.kornet.net>, 2000³â 5¿ù 18ÀÏ


 

Index

À̸§
»ç¿ë¹ý
¼³¸í
SYSTEM CALLS
¹Ýȯ°ª
¿¡·¯
ȣȯ
°ü·Ã Ç׸ñ
¿ªÀÚ

This document was created by man2html, using the manual pages.
Time: 08:06:58 GMT, March 25, 2004