remap_file_pages

REMAP_FILE_PAGES(2)        Linux Programmer's Manual       REMAP_FILE_PAGES(2)



åå
       remap_file_pages - éç·å½¢ãã¡ã¤ã«ãããã³ã°ãä½æããã

æ¸å¼
       #define _GNU_SOURCE         /* feature_test_macros(7) åç§ */
       #include <sys/mman.h>

       int remap_file_pages(void *addr, size_t size, int prot,
                            ssize_t pgoff, int flags);

説æ
       remap_file_pages()  ã·ã¹ãã ã³ã¼ã«ã¯éç·å½¢ãªãããã³ã°ã
       ã¤ã¾ããã¡ã¤ã«ã®ãã¼ã¸ãã¡ã¢ãªä¸ã§é£ç¶ããªãé çªã§ãããããã
       ãããã³ã°ãä½æããããã«ä½¿ãããã remap_file_pages()  ã使ãæ¹ã mmap(2)
       ãç¹°ãè¿ãã¦ä½¿ãããåªãã¦ããç¹ã¯ã åèã®æ¹æ³ã§ã¯ã«ã¼ãã«ã VMA (Virtual Memory
       Area, ä»®æ³ã¡ã¢ãªé å) ãã¼ã¿æ§é ä½ã追å ã§ä½æããå¿è¦ããªããã¨ã§ããã

       éç·å½¢ãããã³ã°ãä½æããããã«ã¯ã 以ä¸ã®ãããªã¹ããããå®è¡ãã:

       1. mmap(2)  ã使ãããããã³ã°ãä½æãã (ãã®ãããã³ã°ã¯æåã¯ç·å½¢ã§ãã)ã
          ãã®ãããã³ã°ã¯ MAP_SHARED ãã©ã°ãæå®ãã¦ä½æãããªããã°ãªããªãã

       2. remap_file_pages()  ã 1 å以ä¸å¼ã³åºãã¦ã
          ãããã³ã°ã®ãã¼ã¸ã¨ãã¡ã¤ã«ã®ãã¼ã¸ã®å¯¾å¿é¢ä¿ãåæ§æããã
          ãã¡ã¤ã«ã®åããã¼ã¸ããããã³ã°é åã®è¤æ°ã®å ´æã« ããããããã¨ãå¯è½ã§ããã

       pgoff 㨠size å¼ãæ°ã¯ããããã³ã°åã§åéç½®ããããã¡ã¤ã«ã®é åãæå®ããã pgoff
       ã¯ãã¡ã¤ã«ãªãã»ããã§ãããåä½ã¯ã·ã¹ãã ã®ãã¼ã¸ãµã¤ãºã§ããã size
       ã¯é åã®é·ãã§ãããåä½ã¯ãã¤ãã§ããã

       addr å¼ãæ°ã¯ 2 ã¤ã®ç®çã§ä½¿ãããã 第 1
       ã®ç®çã¯ããã®å¼ãæ°ã«ãã£ã¦åç·¨æããããã¼ã¸ã® ãããã³ã°ãèå¥ãããã¨ã§ããã ãã£ã¦ addr
       㯠mmap(2)  ã®å¼ã³åºãã§éå»ã«ããããããé ååã®ã¢ãã¬ã¹ã§ãªããã°ãªããªãã 第 2
       ã®ç®çã¯ã pgoff 㨠size ã§èå¥ããããã¡ã¤ã«ãã¼ã¸ãç½®ãããäºå®ã®ã¢ãã¬ã¹ãã addr
       ã«ãã£ã¦æå®ãããã¨ã§ããã

       addr 㨠size ã«æå®ããå¤ã¯ãã·ã¹ãã ã®ãã¼ã¸ãµã¤ãºã®åæ°ã¨ãã¹ãã§ããã
       ãã以å¤ã®å ´åãã«ã¼ãã«ã¯ã両æ¹ãã®å¤ã æãè¿ããã¼ã¸ãµã¤ãºã®åæ°ã¸ãåãä¸ãããã

       prot å¼ãæ°ã¯ 0 ã«æå®ãããªããã°ãªããªãã

       flags å¼ãæ°ã¯ mmap(2)  ã®ãã®ã¨åãæå³ã§ãããã MAP_NONBLOCK
       以å¤ã®å¨ã¦ã®ãã©ã°ã¯ç¡è¦ãããã

è¿ãå¤
       æåããå ´åã remap_file_pages()  㯠0 ãè¿ãã ã¨ã©ã¼ã®å ´åã-1 ãè¿ããã errno
       ãé©åã«è¨å®ãããã

ã¨ã©ã¼
       EINVAL addr ã MAP_SHARED ãã©ã°ãæå®ãã¦ä½æãããæå¹ãªãããã³ã°ãåç§ãã¦ããªãã

       EINVAL addr, size, prot, pgoff ã®ãããããä¸æ£ã§ããã

ãã¼ã¸ã§ã³
       remap_file_pages()  ã·ã¹ãã ã³ã¼ã«ã¯ Linux 2.5.46 ã§ç»å ´ããã glibc
       ã§ã®ãµãã¼ã㯠glibc ãã¼ã¸ã§ã³ 2.3.3 ã§è¿½å ãããã

æºæ
       remap_file_pages()  ã·ã¹ãã ã³ã¼ã«ã¯ Linux åºæã®ãã®ã§ããã

é¢é£é ç®
       getpagesize(2), mmap(2), mmap2(2), mprotect(2), mremap(2), msync(2)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.51 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



Linux                             2008-04-22               REMAP_FILE_PAGES(2)