SYSTEM CALL: shmget(); PROTOTYPE: int shmget ( key_t key, int size, int shmflg ); RETURNS: shared memory segment identifier on success -1 on error: errno = EINVAL (Invalid segment size specified) EEXIST (Segment exists, cannot create) EIDRM (Segment is marked for deletion, or was removed) ENOENT (Segment does not exist) EACCES (Permission denied) ENOMEM (Not enough memory to create segment) NOTES:
shmget()ÀÇ Ã¹¹ø° ¾Æ±Ô¸ÕÆ®´Â Å°°ªÀÌ´Ù(ftok()È£Ãâ¿¡ ÀÇÇØ ¹ÝȯµÈ). ÀÌ Å°°ªÀº Ä¿³Î¾È¿¡ Á¸ÀçÇÏ´Â ´Ù¸¥ °øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®ÀÇ Å°°ª°ú ºñ±³µÇ¾îÁø´Ù. À̶§, ¿±â ³ª Á¢±Ù µ¿ÀÛÀº shmflg ¾Æ±Ô¸ÕÆ®ÀÇ ³»¿ë¿¡ ´Þ·ÁÀÖ´Ù.
IPC_CREAT°¡ È¥ÀÚ »ç¿ëµÇ¸é, shmget()Àº »õ·Ó°Ô ¸¸µé¾îÁø ¼¼±×¸ÕÆ®ÀÇ ¼¼±×¸ÕÆ® È®ÀÎÀÚ¸¦ ¹ÝȯÇϰųª °°Àº Å°°ªÀ» °¡Áø ¼¼±×¸ÕÆ®°¡ Á¸ÀçÇÏ¸é ±× ¼¼±×¸ÕÆ®ÀÇ È®ÀÎÀÚ¸¦ ¹ÝȯÇÑ´Ù. IPC_EXCLÀÌ IPC_CREAT¿Í ÇÔ²² »ç¿ëµÈ´Ù¸é, »õ·Î¿î ¼¼±×¸ÕÆ®°¡ ¸¸µé¾î Áö°Å³ª ¼¼±×¸ÕÆ®°¡ Á¸ÀçÇϸé, -1°ªÀ» °¡Áö¸ç È£ÃâÀº ½ÇÆÐÇÑ´Ù. IPC_EXCLÀº ±× ÀÚü·Î´Â ¾µ¸ð°¡ ¾øÁö¸¸, IPC_CREAT¿Í Á¶ÇÕµÉ ¶§, Á¸ÀçÇÏÁö ¾Ê´Â ¼¼±×¸ÕÆ®°¡ Á¢±ÙÀ» À§ÇØ ¿¸®´Â °ÍÀ» ¸·´Âµ¥ »ç¿ëµÈ´Ù.
´Ù½Ã Çѹø, ºÎ°¡ÀûÀÎ 8Áø ¸ðµå´Â ¸¶½ºÅ©¾È¿¡ ORµÉ ¼ö ÀÖ´Ù.
°øÀ¯ ¸Þ¸ð¸® ¼¼±×¸ÕÆ®¸¦ ¸¸µé°í À§Ä¡½ÃÅ°±â À§ÇÑ wrapper ÇÔ¼ö¸¦ ¸¸µé¾î º¸ÀÚ:
int open_segment( key_t keyval, int segsize ) { int shmid; if((shmid = shmget( keyval, segsize, IPC_CREAT | 0660 )) == -1) { return(-1); } return(shmid); }
ÇÁ·Î¼¼½º°¡ ÁÖ¾îÁø ¼¼±×¸ÕÆ®ÀÇ À¯È¿ÇÑ IPC È®ÀÎÀÚ¸¦ °¡Áø ÈÄ, ´ÙÀ½ ´Ü°è´Â ÇÁ·Î¼¼½º°¡ ÀÚ½ÅÀÇ ÁÖ¼Ò °ø°£¿¡ ¼¼±×¸ÕÆ®¸¦ ±×¸®°Å³ª(map) ºÙÀÌ´Â(attach) °ÍÀÌ´Ù.
Copyright (c) 1996,1997 by Euibeom.Hwang & SangEun.Oh All Rights Reserved
Email To:Webmaster ,
Another address
LAST UPDATE Nov 28,1997
Created Nov 28,1997