semget

å称
     semget — ã»ããã© ID ãåå¾ãã

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <sys/types.h> <sys/ipc.h> <sys/sem.h> int semget(key_t key, int nsems,
     int flag)

解説
     key 㨠flag ã®å¤ã«åºã¥ãã semget() ã¯æ°ãã«ä½æããããããã㯠以åããå‐
     å¨ããã»ããã©éåã®èå¥åãè¿ãã¾ãã ãã¼ã¯ãã¡ã¤ã«åã«é¡ä¼¼ãã¦ãã¾ãã ãã¼ã¯ IPC
     ãªãã¸ã§ã¯ãã«ååãä»ãããã³ãã«ãæä¾ãã¾ãã ãã¼ãæå®ããæ¹æ³ã¯ 3 ã¤ããã¾ã:

     IPC_PRIVATE ãæå®ã§ãã¾ãã ãã®å ´åãæ°ãã IPC ãªãã¸ã§ã¯ããä½æããã¾ãã

     æ´æ°å®æ°ãæå®ã§ãã¾ãã key ã«å¯¾å¿ãã IPC ãªãã¸ã§ã¯ããæå®ããã¦ãããã ããã
         IPC_CREAT ãããã flag å¼æ°ã§è¨å®ãã¦ããå ´åãæ°ãã IPC ãªãã¸ã§ã¯ããä½æããã¾ãã

     ftok(3) é¢æ°ã使ç¨ãã¦ããã¹åãããã¼ãçæã§ãã¾ãã

     æ°ããä½æããã IPC ãªãã¸ã§ã¯ãã®ã¢ã¼ãã¯ã次ã®å®æ°ã®è«çå ( OR ) ã flag
     å¼æ°ã«è¨å®ãããã¨ã§æ±ºå®ããã¾ã:

     SEM_R         ã¦ã¼ã¶ç¨ã®èªåãã¢ã¯ã»ã¹

     SEM_A         ã¦ã¼ã¶ç¨ã®æ¸æãã¢ã¯ã»ã¹

     (SEM_R>>3)    ã°ã«ã¼ãç¨ã®èªåãã¢ã¯ã»ã¹

     (SEM_A>>3)    ã°ã«ã¼ãç¨ã®æ¸æãã¢ã¯ã»ã¹

     (SEM_R>>6)    ãã®ä»ç¨ã®èªåãã¢ã¯ã»ã¹

     (SEM_A>>6)    ãã®ä»ç¨ã®æ¸æãã¢ã¯ã»ã¹

     æ°ããã»ããã©éåãä½æããã¦ããå ´åã nsems ã使ç¨ãã¦ãéåã®ä¸‐
     ã«å¥ããå¿è¦ã®ããã»ããã©ã®æ°ã示ãã¾ãã ããã§ãªãå ´åã nsems ã 0 ã¨ãã¦æå®ã§ãã¾ãã

æ»ãå¤
     semget() ã·ã¹ãã ã³ã¼ã«ã¯ãæ£å¸¸ã«å®äºããã¨ã»ããã©éåã®èå¥åãè¿ãã¾ãã
     ããã§ãªãå ´åã¯ã-1 ãè¿ããã¨ã©ã¼ã示ãããã« errno ãè¨å®ãã¾ãã

ã¨ã©ã¼
     semget() ã·ã¹ãã ã³ã¼ã«ã¯æ¬¡ã®å ´åã«å¦çã«å¤±æãã¾ã:

     [EACCES]           ã¢ã¯ã»ã¹ãã¼ããã·ã§ã³é害ã

     [EEXIST]           IPC_CREAT ããã³ IPC_EXCL ãæå®ããã¦ããã®ã«ã key
                        ã«å¯¾å¿ããã»ããã©éåãæ¢ã«åå¨ãã¾ãã

     [EINVAL]           è¦æ±ãããã»ããã©ã®æ°ãã
                        ã·ã¹ãã ãéååä½ã§èª²ãã¦ããæ大å¤ãè¶éãã¦ãã¾ãã

     [ENOSPC]           å©ç¨å¯è½ãªã»ããã©ãä¸è¶³ãã¦ãã¾ãã

     [ENOSPC]           ã«ã¼ãã«ã struct semid_ds ãå²ãå½ã¦ããã¾ããã§ããã

     [ENOENT]           key ã«å¯¾å¿ããã»ããã©éåãè¦ã¤ãããããã®éã« IPC_CREAT
                        ãæå®ããã¦ãã¾ããã§ããã

é¢é£é ç®
     semctl(2), semop(2), ftok(3)