Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux Çý¶¯mmap²Ù×÷


Èý¡¢VMAºÍPAGE½á¹¹ ºÍmmapº¯Êý
 
1.page  Ö÷Òª³ÉÔ±
   atomic_t count; 
//Õâ¸öÒ³µÄÒýÓÃÊý. µ±Õâ¸ö count µôµ½ 0, ÕâÒ³±»·µ»Ø¸ø¿ÕÏÐÁбí.
void *virtual; 
//Èç¹ûÒ³±»Ó³É䣬Ôò±íʾÕâÒ³µÄÄÚºËÐéÄâµØÖ·; ·ñÔò, NULL.
unsigned long flags; 
//ÃèÊöҳ״̬µÄÒ»Ì×λ±êÖ¾. ÕâЩ°üÀ¨ PG_locked, Ëüָʾ¸ÃÒ³ÔÚÄÚ´æÖÐÒѱ»¼ÓËø, ÒÔ¼° PG_reserved,
//Ëü·ÀÖ¹ÄÚ´æ¹ÜÀíϵͳʹÓøÃÒ³
 
2.vm_area_struct  Ö÷Òª³ÉÔ±
unsigned long vm_start;//VMA ¿ªÊ¼ÓÚ
unsigned long vm_end; //VMA ½áÊø
struct file *vm_file; 
//Ö¸ÏòºÍÕâ¸öÇø(Èç¹ûÓÐÒ»¸ö)¹ØÁªµÄ struct file ½á¹¹µÄÖ¸Õë.
unsigned long vm_pgoff; 
//ÎļþÖÐÇøµÄÆ«ÒÆ, ÒÔÒ³¼Æ. µ±Ò»¸öÎļþºÍÉ豸±»Ó³Éä, ÕâÊÇÓ³ÉäÔÚÕâ¸öÇøµÄµÚÒ»Ò³µÄÎļþλÖÃ.?????
unsigned long vm_flags; 
// É豸Çý¶¯³£ÓõıêÖ¾ÊÇ VM_IO ºÍ VM_RESERVUED. 
//VM_IO ±êÖ¾Ò»¸ö VMA ×÷ΪÄÚ´æÓ³ÉäµÄ I/O Çø,×èÖ¹Õâ¸öÇø±»°üº¬ÔÚ½ø³ÌºËת´¢£¿£¿£¿ÖÐ. 
//VM_RESERVED ¸æÖªÄÚ´æ¹ÜÀíϵͳ²»ÒªÊÔͼ½»»»³öÕâ¸ö VMA;
struct vm_operations_struct *vm_ops; 
//²Ù×÷
//void (*open)(struct vm_area_struct *vma);  VMA¸Õ¸Õ²úÉúʱ£¬´Ëº¯Êý±»µ÷ÓÃÀ´³õʼ»¯VMA
//void (*close)(struct vm_area_struct *vma);  µ±Ò»¸öÇø±»Ïú»Ù, Äں˵÷ÓÃËüµÄ¹Ø±Õ²Ù×÷
//struct page *(*nopage)(struct vm_area_struct *vma, unsigned long address, int *type); 
//Èç¹û nopage ·½·¨Ã»Óж¨Òå,Äں˷ÖÅäÒ»¸ö¿ÕÒ³.½ø³Ì´æÈ¡²»ÔÚÄÚ´æÖÐÓÐЧ VMA µÄҳʱ,nopage ·½·¨±»µ÷ÓÃ(Èç¹ûËü±»¶¨Òå)
//int (*populate)(struct vm_area_struct *vm, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int
nonblock); 
//ÔÚËüÃDZ»Óû§¿Õ¼ä´æȡ֮ǰ,ÔÊÐíÄÚºË"Ô¤´í"Ò³µ½ÄÚ´æ. Çý¶¯Í¨³£Ã»ÓбØҪʵÏÖÕâ¸öÌî³ä·½·¨
void *vm_private_data; 
//Çý¶¯¿ÉÒÔÓÃÀ´´æ´¢ËüµÄ×ÔÉíÐÅÏ¢µÄ³ÉÔ±.
 
3.mmapÓû§¿Õ¼äµ÷ÓÃÓëÄں˿ռäµ÷ÓÃ
void *mmap(void *start,size_t length,int prot,int flags,int fd,off_t offset);
//start Ö¸ÏòÓû¶ÔÓ¦µÄÄÚ´æÆðʼµØÖ·£¬Í¨³£ÉèΪNULL£¬´ú±íÈÃϵͳ×Ô¶¯Ñ¡¶¨µØÖ·£¬¶ÔÓ¦³É¹¦ºó¸ÃµØÖ·»á·µ»Ø
//²ÎÊýlength´ú±í½«ÎļþÖжà´óµÄ²¿·Ö¶ÔÓ¦µ½ÄÚ´æ¡£
//²ÎÊýprot´ú±íÓ³ÉäÇøÓòµÄ±£»¤·½Ê½
//fdÎļþÃèÊö·û
//²ÎÊýoff


Ïà¹ØÎĵµ£º

¡¾linux¡¿c++ ÄÚ´æ¹ÜÀí£¨¶þ£©

3. Ö¸ÕëÓëÊý×éµÄ±È½Ï
²»Í¬µã£º
      Êý×飺ҪôÔÚ¾ªÌì´æ´¢ÇøÓò±»´´½¨£¨ÈçÈ«¾ÖÊý×飩£¬ÒªÃ´ÔÚÕ»Éϱ»´´½¨¡£Êý×éÃû¶ÔÓ¦×Å£¨¶ø²»ÊÇÖ¸Ïò£©Ò»¿éÄڴ棬ÆäµØÖ·ÓëÈÝÁ¿ÔÚÉúÃüÖÜÆÚÄÚ±£³Ö²»±ä£¬Ö»ÓÐÊý×éµÄÄÚÈÝ¿ÉÒԸı䡣
Ö¸Õ룺¿ÉÒÔËæʱָÏòÈÎÒâÀàÐ͵ÄÄÚ´æ¿é£¬ËüµÄÌØÕ÷ÊÇ“¿É±ä”£¬ËùÒÔÎÒÃdz£Óà ......

ÓÃSource Insight½¨Á¢Ò»¸öLinuxÄں˴úÂ빤³Ì


¾ßÌå²½ÖèÈçÏ£º
£¨Ò»£©´ò¿ªSource Insight£¬µ¥»÷¡¾ÏîÄ¿¡¿°´Å¥£¬µ¯³öÏÂÀ­²Ëµ¥¡£
£¨¶þ£©µ¥»÷¡¾ÐÂÏîÄ¿¡¿°´Å¥£¬µ¯³ö¡¾ÐÂÏîÄ¿¡¿¶Ô»°¿ò£¬ÊäÈëÏîÄ¿ÃûºÍ´æ·Å·¾¶£¬µ¥»÷¡¾È·¶¨¡¿°´Å¥¡£Èçͼ1Ëùʾ¡£
 
ͼ1 ÐÂÏîÄ¿¶Ô»°¿ò
ÎÄÕÂÀ´Ô´£ºhttp://top-e.org/jiaoshi/html/539.html
£¨Èý£©µ¯³ö¡¾Ìí¼Óɾ³ýÎļþ¡¿¶Ô»°¿ò£¬ÔÚÄÚºËÔ´´ú ......

Linux¿ìËÙ¹¹½¨apache web·þÎñÆ÷

¡¡apache·þÎñÆ÷µÄ×îÐÂÎȶ¨·¢²¼°æ±¾ÊÇhttpd-2.2..0,¹Ù·½ÏÂÔصØÖ·ÊÇ£ºhttp://httpd.apache.org/download.cgi¡£ÎÒÃÇͨ¹ýÏÂÃæµÄ²½ÖèÀ´¿ìËٵĴһ¸öweb·þÎñÆ÷¡£
¡¡¡¡1¡¢ ÏÂÔØÔ´ÂëÎļþhttpd-2.2.0.tar.gz µ½linux·þÎñÆ÷µÄij¸öĿ¼¡£
¡¡¡¡2¡¢ ½âѹÎļþ # tar zxvf httpd-2.2.0.tar.gz .
¡¡¡¡3¡¢ ÅäÖÃ # ./c ╟refix=/usr ......

[ת]Àí½âLinuxµÄÐÔÄÜ

ÏîÄ¿Öг£Óöµ½ÐèÒª¶ÔÄ¿Ç°ÔËÐеÄϵͳ½øÐÐЧÂÊ·ÖÎö£¬»òÅöµ½¿Í»§×ÉѯÈçºÎÓÅ»¯ÏµÍ³µÄЧÂÊÎÊÌâ¡£¸ü¶àµÄÇé¿öÊÇ£¬ÔÚϵͳ³öÏÖÎÊÌâµÄʱºò£¬ÐèÒª·ÖÎöÔ­Òò£¬¶¨Î»ÏµÍ³¹ÊÕÏ»òÆ¿¾±£¬µ±È»£¬×îºÃÊÇ¿ÉÒÔÒ»²¢½â¾ö¹ÊÕÏ¡£µ«Êµ¼ÊÉÏ£¬²Ù×÷ϵͳÓÅ»¯ÊÇÒ»¸ö·Ç³£¸´ÔÓµÄÎÊÌ⣬¿öÇÒlinuxÓÐ×Ô¼ºÒ»Ì×ÓбðÓÚÆäËû²Ù×÷ϵͳ¹ÜÀíµÄ»úÖÆ£¬ÓÉ´Ë»áÒýÆðºÜ¶à²»±ØÒªµÄÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ