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

LinuxÉ豸Çý¶¯±à³ÌÖ®ÄÚ´æÓëI/O²Ù×÷£¨×ª£©

תÖÁ£º http://dev.yesky.com/412/2639912.shtml
¶ÔÓÚÌṩÁËMMU£¨´æ´¢¹ÜÀíÆ÷£¬¸¨Öú²Ù×÷ϵͳ½øÐÐÄÚ´æ¹ÜÀí£¬ÌṩÐéʵµØַת»»µÈÓ²¼þÖ§³Ö£©µÄ´¦ÀíÆ÷¶øÑÔ£¬LinuxÌṩÁ˸´ÔӵĴ洢¹ÜÀíϵͳ£¬Ê¹µÃ½ø³ÌËùÄÜ·ÃÎʵÄÄÚ´æ´ïµ½4GB¡£
¡¡¡¡½ø³ÌµÄ4GBÄÚ´æ¿Õ¼ä±»ÈËΪµÄ·ÖΪÁ½¸ö²¿·Ö--Óû§¿Õ¼äÓëÄں˿ռ䡣Óû§¿Õ¼äµØÖ··Ö²¼´Ó0µ½3GB(PAGE_OFFSET£¬ÔÚ0x86ÖÐËüµÈÓÚ0xC0000000)£¬3GBµ½4GBΪÄں˿ռ䣬ÈçÏÂͼ£º
¡¡¡¡Äں˿ռäÖУ¬´Ó3Gµ½vmalloc_startÕâ¶ÎµØÖ·ÊÇÎïÀíÄÚ´æÓ³ÉäÇøÓò£¨¸ÃÇøÓòÖаüº¬ÁËÄں˾µÏñ¡¢ÎïÀíÒ³¿ò±ímem_mapµÈµÈ£©£¬±ÈÈçÎÒÃÇʹÓõÄVMwareÐéÄâϵͳÄÚ´æÊÇ160M£¬ÄÇô3G¡«3G+160MÕâƬÄÚ´æ¾ÍÓ¦¸ÃÓ³ÉäÎïÀíÄÚ´æ¡£ÔÚÎïÀíÄÚ´æÓ³ÉäÇøÖ®ºó£¬¾ÍÊÇvmallocÇøÓò¡£¶ÔÓÚ160MµÄϵͳ¶øÑÔ£¬vmalloc_startλÖÃÓ¦ÔÚ3G+160M¸½½ü£¨ÔÚÎïÀíÄÚ´æÓ³ÉäÇøÓëvmalloc_startÆڼ仹´æÔÚÒ»¸ö8MµÄgapÀ´·ÀÖ¹Ô¾½ç£©£¬vmalloc_endµÄλÖýӽü4G(×îºóλÖÃϵͳ»á±£ÁôһƬ128k´óСµÄÇøÓòÓÃÓÚרÓÃÒ³ÃæÓ³Éä)£¬ÈçÏÂͼ£º
¡¡¡¡kmallocºÍget_free_pageÉêÇëµÄÄÚ´æλÓÚÎïÀíÄÚ´æÓ³ÉäÇøÓò£¬¶øÇÒÔÚÎïÀíÉÏÒ²ÊÇÁ¬ÐøµÄ£¬ËüÃÇÓëÕæʵµÄÎïÀíµØÖ·Ö»ÓÐÒ»¸ö¹Ì¶¨µÄÆ«ÒÆ£¬Òò´Ë´æÔڽϼòµ¥µÄת»»¹Øϵ£¬virt_to_phys()¿ÉÒÔʵÏÖÄÚºËÐéÄâµØַת»¯ÎªÎïÀíµØÖ·£º
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
extern inline unsigned long virt_to_phys(volatile void * address)
{
¡¡return __pa(address);
}
¡¡¡¡ÉÏÃæת»»¹ý³ÌÊǽ«ÐéÄâµØÖ·¼õÈ¥3G£¨PAGE_OFFSET=0XC000000£©¡£
¡¡¡¡ÓëÖ®¶ÔÓ¦µÄº¯ÊýΪphys_to_virt()£¬½«ÄÚºËÎïÀíµØַת»¯ÎªÐéÄâµØÖ·£º
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
extern inline void * phys_to_virt(unsigned long address)
{
¡¡return __va(address);
}
¡¡¡¡virt_to_phys()ºÍphys_to_virt()¶¼¶¨ÒåÔÚinclude\asm-i386\io.hÖС£
¡¡¡¡¶øvmallocÉêÇëµÄÄÚ´æÔòλÓÚvmalloc_start¡«vmalloc_endÖ®¼ä£¬ÓëÎïÀíµØַûÓмòµ¥µÄת»»¹Øϵ£¬ËäÈ»ÔÚÂß¼­ÉÏËüÃÇÒ²ÊÇÁ¬ÐøµÄ£¬µ«ÊÇÔÚÎïÀíÉÏËüÃDz»ÒªÇóÁ¬Ðø¡£
¡¡¡¡ÎÒÃÇÓÃÏÂÃæµÄ³ÌÐòÀ´ÑÝʾkmalloc¡¢get_free_pageºÍvmallocµÄÇø±ð£º
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
MODULE_LICENSE("GPL"); 
unsigned char *pagemem;
unsigned char *kmallocmem;
unsigned char *vmallocmem;
int __init mem_module_init(void)
{
¡¡//×îºÃÿ´ÎÄÚ´æÉêÇ붼¼ì²éÉêÇ


Ïà¹ØÎĵµ£º

µ÷ÕûlinuxÐéÄâ»úÓ²ÅÌ´óС

°²×°Ê±Ó²Å̿ռ䲻×ã
    ¹ÒÔØÒ»¸öÐÂÓ²ÅÌ
    ÏȽ«ÐéÄâ»úPower Off£¬ÔÚVirtual Machine Setting¶Ô»°¿òÀïµã»÷×óϽǵēAdd”£¬Ñ¡Ôñ“Hard Disk”£¬Ö®ºóÑ¡Ôñ“Create a new virtual disk”£¬·ÖÅäÈÝÁ¿£¬ÆäËûĬÈÏÅäÖá£
    Æô¶¯ÐéÄâ»úϵͳ£¬Óà ......

Socket±à³Ì£ºÓÉLinuxÏòWindowsÒÆÖ²ÎÊÌâ


ת×Ô£ºhttp://www.cic.tsinghua.edu.cn/jdx/book1/CHAPTER3.htm
 
ÔÚÔ´Îļþ¿ªÊ¼Ôö¼Ó#include <winsock.h>Óï¾ä¡£
µ÷ÓÃWSAStartup()º¯Êý³õʼ»¯Windows Sockets DLL£¬²¢ÔÚ½áÊøʱµ÷ÓÃWSACleanup()º¯Êý֪ͨWindows Sockets DLLÊÍ·Å×ÊÔ´¡£
½«Ì×½Ó×ÖµÄÀàÐÍΪint¸ÄΪSOCKET¡£
»ñÈ¡¡¢ÉèÖôíÎóÂ벻ҪʹÓÃÈ«¾Ö±äÁ¿er ......

linuxÇý¶¯Ö®mmapʵÀý

// Linux Device Driver Template/Skeleton with mmap
// Kernel Module
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#inclu ......

linux¿Í»§¶ËÁ¬½ÓºóÖÐÎÄÂÒÂë½â¾ö


ÓÃSSHµÇ½Զ³ÌµÄlinux·þÎñÆ÷»òÓÃwinä¯ÀÀÔËÐÐsambaµÄlinux·þÎñÆ÷ÖÐÓÐÖÐÎÄÃûµÄÎļþ¼ÐµÄʱºò£¬¿´µ½ÀïÃæµÄÖÐÎÄÎļþÃû¶¼ÊÇÂÒÂ룬±à¼­ÎĵµµÄʱºò¶¼ÊÇ´®Ðеģ¬Ã¿´ÎÒªexport LANG=enÂé·³ËÀÁË¡£
ÉÏÍøËÄ´¦ËÑË÷£¬Çó½Ì¸ßÈË£¬µÃ´Ë°ì·¨¡£
(1) ´ò¿ª/etc/sysconfig/i18n
ÉèÖÃΪ£º
LANG="zh_CN.GB2312"
LANGUAGE="zh_CN.GB18030:zh_CN ......

LinuxϵͳÄں˶¨Ê±Æ÷»úÖÆÏê½â

 LinuxÄÚºË2.4°æÖÐÈ¥µôÁËÀÏ°æ±¾ÄÚºËÖеľ²Ì¬¶¨Ê±Æ÷»úÖÆ£¬¶øÖ»Áô϶¯Ì¬¶¨Ê±Æ÷¡£ÏàÓ¦µØÔÚtimer_bh()º¯ÊýÖÐÒ²²»ÔÙͨ¹ýrun_old_timers()º¯ÊýÀ´ÔËÐÐÀÏʽµÄ¾²Ì¬¶¨Ê±Æ÷¡£¶¯Ì¬¶¨Ê±Æ÷Ó뾲̬¶¨Ê±Æ÷Õâ¶þ¸ö¸ÅÄîÊÇÏà¶ÔÓÚLinuxÄں˶¨Ê±Æ÷»úÖƵĿÉÀ©Õ¹¹¦ÄܶøÑԵģ¬¶¯Ì¬¶¨Ê±Æ÷ÊÇÖ¸Äں˵Ķ¨Ê±Æ÷¶ÓÁÐÊÇ¿ÉÒÔ¶¯Ì¬±ä»¯µÄ£¬È»¶ø¾Í¶¨Ê±Æ÷±¾Éí¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ