.\" .\" Copyright (c) 1995 David Hovemeyer .\" .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" %FreeBSD: src/lib/libc/sys/semop. 2, v 1.7. 2.6 2001/12/14 18:34:01 ru Exp % .\" .\" WORD: atomic ºÒ°¡ºÐÀÎ [POSIX] .\" WORD: adjust on exit Á¾·á½Ã Á¶Á¤ .\" $FreeBSD: doc/ja_JP.eucJP/man/man2/semop. 2, v 1.8 2001/12/23 00:03:42 horikawa Exp $ .Dd September 22, 1995 .Dt SEMOP 2 .Os .Sh ¸íĪ .Nm semop .Nd semaphore ÁýÇÕ¿¡ ´ëÇÑ ºÒ°¡ºÐÀÎ Á¶ÀÛÀÇ ¹è¿­ .Sh ÇÁ·Î±×·¥ ¶óÀ̺귯¸® .Lb libc .Sh ¼­½Ä .In sys/types.h .In sys/ipc.h .In sys/sem.h .Ft int .Fn semop "int semid" "struct sembuf array[]" "unsigned nops" .Sh ÇØ¼³ .Fn semop (Àº)´Â, .Fa semid ÇÏÁö¸¸ °¡¸®Å°´Â semaphore ÁýÇÕ¿¡ ´ëÇØ¼­, .Fa array ÇÏÁö¸¸ °¡¸®Å°´Â Á¶ÀÛÀÇ ¹è¿­À» ºÒ°¡ºÐ¿¡ ½ÇÇàÇÕ´Ï´Ù. .Fa array ÀÇ ±æÀÌ´Â .Fa nops ±×¸®°í °¡¸®Åµ´Ï´Ù. °¢ Á¶ÀÛÀº .Fa "struct sembuf" ¾È¿¡ encode µÇ°í ÀÖ¾î .Fa "struct sembuf" (Àº)´Â ´ÙÀ½°ú °°ÀÌ Á¤Àǵ˴ϴÙ. .Bd -literal .\" .\" From .\" struct sembuf { u_short sem_num; /* semaphore ¹øÈ£ */ short sem_op; /* semaphore Á¶ÀÛ */ short sem_flg; /* Á¶ÀÛ Ç÷¡±× */ }; .Ed .Pp .Fa array ¾ÈÀÇ °¢ ¿ä¼Ò¿¡ °ü°èµÇ¾î, .Fa sem_op (¿Í)°ú .Fa sem_flg (Àº)´Â, ÁýÇÕ³»ÀÇ semaphore ¹øÈ£ .Fa sem_num ¿¡ ´ëÇØ¼­ ½ÇÇàµÇ´Â Á¶ÀÛÀ» °áÁ¤ÇÕ´Ï´Ù. ÁöÁ¤ÇÑ Á¶ÀÛÀÇ µ¿ÀÛÀ» º¯°æÇϱâ À§Çؼ­, SEM_UNDO (¿Í)°ú IPC_NOWAIT ÀÇ °ªÀÇ ³í¸®ÇÕ ( .Em OR )(À»)¸¦ ÃëÇØ .Fa sem_flg ¸â¹ö¿¡ ³Ö´Â °ÍÀÌ °¡´ÉÇÕ´Ï´Ù. .Pp ½ÇÇàµÇ´Â Á¶ÀÛÀº ´ÙÀ½°ú °°ÀÌ .Fa sem_op ÀÇ °ª¿¡ ÀÇÁ¸ÇÕ´Ï´Ù. .\" .\" This section is based on the description of semop() in .\" Stevens, _Advanced Programming in the UNIX Environment_. .\" .Bl -bullet .It .Fa sem_op ÇÏÁö¸¸ Á¤ÀÇ °æ¿ì, semaphoreÀÇ °ªÀ» .Fa sem_op ÀÇ °ª¸¸ Áõ°¡½Ãŵ´Ï´Ù. SEM_UNDO (À»)¸¦ ÁöÁ¤ÇßÀ» °æ¿ì, semaphoreÀÇ Á¾·á½Ã Á¶Á¤Ä¡¸¦ .Fa sem_op ÀÇ °ª¸¸ °¨¼Ò½Ãŵ´Ï´Ù. .Fa sem_op ¿¡ ´ëÇÑ Á¤ÀÇ °ªÀº, ÀϹÝÀûÀ¸·Î, semaphore¿¡ ¿¬°á½Ãų ¼ö ÀÖ¾ú´ø ÀÚ¿øÀ» ¸±¸®½º ÇÏ´Â ÇÁ·Î¼¼½º¿¡ ´ëÀÀÇÕ´Ï´Ù. .It .Fa sem_op ÇÏÁö¸¸ ºÎÀÇ °æ¿ìÀÇ µ¿ÀÛÀº, semaphoreÀÇ ÇöÀçÀÇ °ª¿¡ ÀÇÁ¸ÇÕ´Ï´Ù. .Bl -bullet .It semaphoreÀÇ ÇöÀçÀÇ °ªÀÌ .Fa sem_op ÀÇ Àý´ëÄ¡¿Í µ¿ÀÏÇѰ¡ ±×°Íº¸´Ù Å« °æ¿ì, semaphoreÀÇ °ªÀ» .Fa sem_op ÀÇ Àý´ëÄ¡¸¸ °¨¼Ò½Ãŵ´Ï´Ù. SEM_UNDO ÇÏÁö¸¸ ÁöÁ¤µÇ¾î ÀÖ´Â °æ¿ì, semaphoreÀÇ Á¾·á½Ã Á¶Á¤Ä¡¸¦ .Fa sem_op ÀÇ Àý´ëÄ¡¸¸ Áõ°¡½Ãŵ´Ï´Ù. .It semaphoreÀÇ ÇöÀç°¡°¡ .Fa sem_op ÀÇ °ª¹Ì¸¸ÀÇ °æ¿ì, ´ÙÀ½ÀÇ ¾î¶² °ÍÀΰ¡°¡ ¹ß»ýÇÕ´Ï´Ù. .\" XXX a *second* sublist? .Bl -bullet .It IPC_NOWAIT (À»)¸¦ ÁöÁ¤ÇßÀ» °æ¿ì, .Fn semop (Àº)´Â ¹Ýȯ°ª .Er EAGAIN ±×¸®°í Áï½Ã º¹±ÍÇÕ´Ï´Ù. .It .Fn semctl ÀÇ IPC_RMID ¿É¼ÇÀ» ÀÌ¿ëÇØ, ´Ù¸¥ ÇÁ·Î¼¼½º°¡ semaphore¸¦ »èÁ¦ÇØ ¹ö·ÈÀ» °æ¿ì, .Fn semop (Àº)´Â ¹Ýȯ°ª .Er EINVAL ±×¸®°í Áï½Ã º¹±ÍÇÕ´Ï´Ù. .It ±× ÀÌ¿ÜÀÇ °æ¿ì, semaphoreÀÇ °ªÀÌ .Fa sem_op ÀÇ Àý´ëÄ¡¿¡ µ¿ÀÏÇѰ¡ ±×°Íº¸´Ù Ä¿Áú ¶§±îÁö, È£Ãâ¿øÇÁ·Î¼¼½º´Â ÈÞ¸é »óŰ¡ µË´Ï´Ù. ÀÌ Á¶°ÇÀÌ ½Ç·Î µÉ ¶§, semaphoreÀÇ °ªÀ» .Fa sem_op ÀÇ Àý´ëÄ¡¸¸ °¨¼Ò½ÃÄÑ, semaphoreÀÇ Á¾·á½Ã Á¶Á¤Ä¡¸¦ .Fa sem_op ÀÇ Àý´ëÄ¡¸¸ Áõ°¡½Ãŵ´Ï´Ù. .El .Pp .Fa sem_op ÇÏÁö¸¸ ºÎÀÇ °ªÀÏ ¶§´Â, ÀϹÝÀûÀ¸·Î, ÀÚ¿øÀÌ ÀÌ¿ë °¡´ÉÇÏ°Ô µÇ´Â °ÍÀ» ÇÁ·Î¼¼½º°¡ ±â´Ù¸®°í ÀÖ´Â °Í¿¡ µË´Ï´Ù. .El .Pp .It .Fa sem_op ÇÏÁö¸¸ 0 ÀÇ °æ¿ì, ÇÁ·Î¼¼½º´Â semaphoreÀÇ °ªÀÌ 0 ÀÌ µÇ´Â °ÍÀ» ±â´Ù¸³´Ï´Ù. ÀÌ¹Ì 0 ÀÇ °æ¿ì´Â, .Fn semop ÀÇ È£Ãâ·ÎºÎÅÍ Áï½Ã º¹±ÍÇÕ´Ï´Ù. ±×·¸Áö ¾ÊÀº °æ¿ì, È£Ãâ¿øÇÁ·Î¼¼½º´Â, semaphoreÀÇ °ªÀÌ 0 ÀÌ µÉ ¶§±îÁö ÈÞ¸é »óŰ¡ µË´Ï´Ù. .El .Pp ÇÁ·Î¼¼½º°¡ »ç¿ëÇϰí ÀÖ´Â semaphore ¸¶´Ù, Ä¿³ÎÀº, ¸ÕÀú ¸»ÇÑ °Íó·³ ¡¸Á¾·á½Ã Á¶Á¤¡¹Ä¡¸¦ º¸°ü À¯ÁöÇÕ´Ï´Ù. ÀÚ¹ßÀûÀÌµç ºñÀÚ¹ßÀûÀ¸·Îµç, ÇÁ·Î¼¼½º°¡ Á¾·áÇÒ °æ¿ì¿¡´Â, °¢ semaphore¿¡ ´ëÇÑ Á¾·á½Ã Á¶Á¤Ä¡°¡ semaphoreÀÇ °ª¿¡ Ãß°¡µË´Ï´Ù. À̰ÍÀ», ÇÁ·Î¼¼½º°¡ ¿¹±â ÇÏÁö ¾Ê°í Á¾·áÇØ ¹ö¸®´Â °æ¿ì¿¡ ÀÚ¿øÀ» ¹Ýµå½Ã ÇØ¹æÇÏ´Â °ÍÀ» ÇÁ·ÎÅØ¼ÇÇϴµ¥ »ç¿ë °¡´ÉÇÕ´Ï´Ù. .Sh ¹Ýȯ°ª .Rv -std semop .Sh ¿¡·¯ .Fn semop (Àº)´Â ´ÙÀ½ÀÇ °æ¿ì¿¡ ½ÇÆÐÇÕ´Ï´Ù. .Bl -tag -width Er .It Bq Er EINVAL .Fa semid ¿¡ ´ëÀÀÇÏ´Â semaphore ÁýÇÕÀÌ ¾ø½À´Ï´Ù. .It Bq Er EACCES Á¶ÀÛ°ú semaphore ÁýÇÕÀÇ ¸ðµåÀÇ »çÀÌ¿¡ ºÒÀÏÄ¡°¡ ÀÖ±â (À§ÇØ)¶§¹®¿¡, ÆÛ¹Ì¼ÇÀÌ °ÅºÎµÇ¾ú½À´Ï´Ù. .It Bq Er EAGAIN semaphoreÀÇ °ªÀÌ .Fa sem_op ¹Ì¸¸À¸·Î, ÇÑÆí IPC_NOWAIT ÇÏÁö¸¸ ÁöÁ¤µÇ¾ú½À´Ï´Ù. .It Bq Er E2BIG ³Ê¹«³ª ¸¹Àº Á¶ÀÛÀÌ ÁöÁ¤µÇ¾ú½À´Ï´Ù. .It Bq Er EFBIG .\" .\" I'd have thought this would be EINVAL, but the source says .\" EFBIG. .\" .Fa sem_num ÇÏÁö¸¸ ÁýÇÕ¿¡ ´ëÇÑ À¯È¿ÇÑ semaphoreÀÇ ¹üÀ§³»¿¡ ¾ø¾ú½À´Ï´Ù. .El .Sh °ü·Ã Ç׸ñ .Xr semctl 2 , .Xr semget 2