MMAP
Section: ¸®´ª½º ÇÁ·Î±×·¡¸Ó ¸Å´º¾ó (2)
Updated: 1996³â 4¿ù 12ÀÏ
Index
Return to Main Contents
À̸§
mmap, munmap - ÆÄÀÏÀ̳ª ÀåÄ¡¸¦ ¸Þ¸ð¸®·Î ´ëÀÀ½ÃÅ°°Å³ª ´ëÀÀÀ» Ǭ´Ù.
»ç¿ë¹ý
#include <unistd.h>
#include <sys/mman.h>
#ifdef _POSIX_MAPPED_FILES
void * mmap(void *start, size_t length, int prot
, int flags, int fd, off_t offset);
int munmap(void *start, size_t length);
#endif
¼³¸í
mmap
ÇÔ¼ö´Â
fd·Î
ÁöÁ¤µÈ ÆÄÀÏ(¶Ç´Â ´Ù¸¥ °´Ã¼)¿¡¼
offsetÀ»
½ÃÀÛÀ¸·Î
length
¹ÙÀÌÆ®¸¸ÅÀ»
start
ÁÖ¼Ò·Î ´ëÀÀ½ÃÅ°µµ·Ï ÇÑ´Ù.
ÀÌ ÁÖ¼Ò´Â ´ÜÁö ±× ÁÖ¼Ò·Î ÇßÀ¸¸é ÁÁ°Ú´Ù´Â Á¤µµÀ̸ç, º¸Åë 0À¸·Î ÁöÁ¤ÇÑ´Ù.
mmap´Â
ÁöÁ¤µÈ ¿µ¿ªÀÌ ´ëÀÀµÈ ½ÇÁ¦ ½ÃÀÛ À§Ä¡¸¦ ¹ÝȯÇÑ´Ù.
prot
ÀÎÀÚ´Â ¿øÇÏ´Â ¸Þ¸ð¸® º¸È£ ¸ðµå¸¦ ¼³Á¤ÇÑ´Ù. ÇØ´ç ºñÆ®´Â ´ÙÀ½°ú °°´Ù.
- PROT_EXEC
-
ÆäÀÌÁö´Â ½ÇÇàµÉ ¼ö ÀÖ´Ù.
- PROT_READ
-
ÆäÀÌÁö´Â ÀÐÀ» ¼ö ÀÖ´Ù.
- PROT_WRITE
-
ÆäÀÌÁö´Â ¾²¿©Áú ¼ö ÀÖ´Ù.
- PROT_NONE
-
ÆäÀÌÁö´Â Á¢±ÙµÉ ¼ö ¾ø´Ù.
flags
ÀÎÀÚ´Â ´ëÀÀµÈ °´Ã¼ÀÇ Å¸ÀÔ, ´ëÀÀ ¿É¼Çµé, ´ëÀÀµÈ ÆäÀÌÁö
º¹»çº»¿¡ ´ëÇÑ ¼öÁ¤ÀÌ ±× ÇÁ·Î¼¼½º¿¡¸¸ º¸ÀÏ °ÍÀÎÁö ´Ù¸¥ ÂüÁ¶ÇÏ´Â ÇÁ·Î¼¼½º¿Í
°øÀ¯ÇÒ °ÍÀÎÁö¸¦ ¼³Á¤ÇÑ´Ù.
ÇØ´ç ºñÆ®µéÀº ´ÙÀ½°ú °°´Ù.
- MAP_FIXED
-
ÁöÁ¤µÈ ÁÖ¼Ò ÀÌ¿ÜÀÇ ´Ù¸¥ ÁÖ¼Ò¸¦ ¼±ÅÃÇÏÁö ¾Ê´Â´Ù.
ÁöÁ¤µÈ ÁÖ¼Ò°¡ »ç¿ëµÉ ¼ö ¾ø´Ù¸é,
mmap˼
½ÇÆÐÇÒ °ÍÀÌ´Ù.
¸¸ÀÏ MAP_FIXED°¡ ÁöÁ¤µÇ¸é,
start´Â
ÆäÀÌÁö Å©±âÀÇ ¹è¼öÀ̾î¾ß ÇÑ´Ù. ÀÌ ¿É¼ÇÀº »ç¿ëÇÏÁö ¾Ê´Â °ÍÀÌ ÁÁ´Ù.
- MAP_SHARED
-
ÀÌ °´Ã¼¸¦ ´ëÀÀ½ÃÅ°´Â ´Ù¸¥ ¸ðµç ÇÁ·Î¼¼½º¿Í ÀÌ ´ëÀÀ ¿µ¿ªÀ» °øÀ¯ÇÑ´Ù.
- MAP_PRIVATE
-
°³º°ÀûÀÎ copy-on-write ´ëÀÀÀ» ¸¸µç´Ù. (´Ù¸¥ ÇÁ·Î¼¼½º¿Í ´ëÀÀ ¿µ¿ªÀ» °øÀ¯ÇÏÁö ¾Ê´Â´Ù.)
MAP_SHARED³ª MAP_PRIVATE Áß Çϳª´Â ¹Ýµå½Ã ¸í½ÃÇØ¾ß ÇÑ´Ù.
À§ ¼¼ Ç÷¡±×´Â POSIX.1b¿¡ ±ÔÁ¤µÇ¾î ÀÖ´Ù.(°ø½ÄÀûÀ¸·Î POSIX.4)
¶ÇÇÑ ¸®´ª½º¿¡´Â MAP_DENYWRITE, MAP_EXECUTABLE ±×¸®°í MAP_ANON(YMOUS)µµ
ÀÖ´Ù.
munmap
½Ã½ºÅÛ ÄÝÀº ÁöÁ¤µÈ ÁÖ¼Ò °ø°£¿¡ ´ëÇÑ ´ëÀÀÀ» Ǭ´Ù. ¹üÀ§³»ÀÇ ÁÖ¼Ò¿¡
´ëÇÑ ÂüÁ¶ °è¼ö¸¦ ´Ã·Á¼ À¯È¿ÇÏÁö ¾Ê´Â ¸Þ¸ð¸® ÂüÁ¶·Î ¸¸µç´Ù.
¹Ýȯ°ª
¼º°ø½Ã,
mmap˼
´ëÀÀµÈ ¿µ¿ªÀÇ Æ÷ÀÎÅ͸¦ ¹ÝȯÇÑ´Ù.
¿¡·¯½Ã, MAP_FAILED(-1)ÀÌ ¸®ÅϵǸç,
errno´Â
Àû´çÇÑ °ªÀ¸·Î ¼³Á¤µÈ´Ù.
¼º°ø½Ã,
munmap˼
0À» ¸®ÅÏÇϸç, ½ÇÆнà -1ÀÌ ¸®ÅϵǸç,
errno°¡
¼³Á¤µÈ´Ù (º¸Åë EINVALÀÌ ¼³Á¤µÈ´Ù).
¿¡·¯
- EBADF
-
fd°¡
À¯È¿ÇÑ ÆÄÀÏ ±â¼úÀÚ°¡ ¾Æ´Ï´Ù (±×¸®°í MAP_ANONYMOUS°¡ ¼³Á¤µÇ¾î
ÀÖÁö ¾Ê´Ù).
- EACCES
-
MAP_PRIVATE°¡ ¼³Á¤µÇ¾úÁö¸¸,
fd°¡
ÀÐÀ» ¼ö ÀÖµµ·Ï ¿·ÁÀÖÁö ¾Ê´Ù. ¶Ç´Â MAP_SHARED¿Í
PROT_WRITE°¡ ¼³Á¤µÇ¾úÁö¸¸,
fd°¡
¾µ ¼ö ÀÖµµ·Ï ¿·ÁÀÖÁö ¾Ê´Ù.
- EINVAL
-
start³ª
length³ª
offset°¡
Àû´çÇÏÁö ¾Ê´Ù (Áï, ³Ê¹« Å©°Å³ª PAGESIZE °æ°è·Î Á¤·ÄµÇ¾î ÀÖÁö ¾Ê´Ù).
- ETXTBUSY
-
MAP_DENYWRITE°¡ ¼³Á¤µÇ¾úÀ¸³ª
fd·Î
ÁöÁ¤µÈ °´Ã¼°¡ ¾²±â À§ÇØ ¿·ÁÀÖ´Ù.
- EAGAIN
-
ÆÄÀÏÀÌ Àá°ÜÀְųª, ³Ê¹« ¸¹Àº ¸Þ¸ð·Î°¡ Àá°ÜÀÖ´Ù.
- ENOMEM
-
»ç¿ëÇÒ ¼ö ÀÖ´Â ¸Þ¸ð¸®°¡ ¾ø´Ù.
ȣȯ
SVr4, POSIX.1b (formerly POSIX.4), 4.4BSD. Svr4 ¹®¼¿¡´Â ENXIO¿Í
ENODEV ¿¡·¯ Äڵ尡 Ãß°¡µÇÀÖ´Ù.
°ü·Ã Ç׸ñ
getpagesize(2),
msync(2),
shm_open(2),
B.O. Gallmeister, POSIX.4, O'Reilly, ÆäÀÌÁö. 128-129¿Í 389-391.
¿ªÀÚ
Á¤°ÈÆ <skyeyes@soback.kornet.net>, 2000³â 5¿ù 14ÀÏ
Index
- À̸§
-
- »ç¿ë¹ý
-
- ¼³¸í
-
- ¹Ýȯ°ª
-
- ¿¡·¯
-
- ȣȯ
-
- °ü·Ã Ç׸ñ
-
- ¿ªÀÚ
-
This document was created by
man2html,
using the manual pages.
Time: 08:06:59 GMT, March 25, 2004