LinuxÖеÄ"Á㿽±´"ÆÊÎö
http://blog.chinaunix.net/u/9861/showart_1890675.html
LinuxÖеÄ"Á㿽±´"ÆÊÎö
Zero Copy I: User-Mode Perspective
Author By Dragan Stancevic
Translated By Love. Katherine
(½âÊÍLinuxÖеÄ"Á㿽±´"ÌØÐÔ£¬ÎªÊ²Ã´ÓÐÓÃÒÔ¼°ºÎ´¦ÐèÒª¸Ä½øÖ®´¦)
Èç½ñ¼¸ºõÿ¸öÈ˶¼Ìý˵¹ýLinuxÖÐËùνµÄ"Á㿽±´"ÌØÐÔ£¬È»¶øÎÒ¾³£Åöµ½Ã»Óгä·ÖÀí½âÕâ¸ö
ÎÊÌâµÄÈËÃÇ¡£Òò´Ë£¬ÎÒ¾ö¶¨Ð´Ò»Ð©ÎÄÕÂÂÔ΢ÉîÈëµÄ½²ÊöÕâ¸öÎÊÌ⣬ϣÍûÄܽ«Õâ¸öÓÐÓõÄÌØ
ÐÔ½âÊÍÇå³þ¡£ÔÚ±¾ÎÄÖУ¬½«´ÓÓû§¿Õ¼äÓ¦ÓóÌÐòµÄ½Ç¶ÈÀ´²ûÊöÕâ¸öÎÊÌ⣬Òò´ËÓÐÒâºöÂÔÁË
¸´ÔÓµÄÄÚºËʵÏÖ¡£
ʲôÊÇ”Á㿽±´”
ΪÁ˸üºÃµÄÀí½âÎÊÌâµÄ½â¾ö·¨£¬ÎÒÃÇÊ×ÏÈÐèÒªÀí½âÎÊÌâ±¾Éí¡£Ê×ÏÈÎÒÃÇÒÔÒ»¸öÍøÂç·þÎñÊØ
»¤½ø³ÌΪÀý£¬¿¼ÂÇËüÔÚ½«´æ´¢ÔÚÎļþÖеÄÐÅϢͨ¹ýÍøÂç´«Ë͸ø¿Í»§ÕâÑùµÄ¼òµ¥¹ý³ÌÖУ¬Ëù
Éæ¼°µÄ²Ù×÷¡£ÏÂÃæÊÇÆäÖеIJ¿·Ö¼òµ¥´ú°¢£º
read(file, tmp_buf, len);
write(socket, tmp_buf, len);
¿´ÆðÀ´²»Äܸü¼òµ¥ÁË¡£ÄãÒ²ÐíÈÏΪִÐÐÕâÁ½¸öϵͳµ÷Óò¢Î´²úÉú¶àÉÙ¿ªÏú¡£Êµ¼ÊÉÏ£¬Õâ¼ò
Ö±´íµÄÒ»ËúºýÍ¿¡£ÔÚÖ´ÐÐÕâÁ½¸öϵͳµ÷ÓõĹý³ÌÖУ¬Ä¿±êÊý¾ÝÖÁÉÙ±»¸´ÖÆÁË4´Î£¬Í¬Ê±·¢Éú
ÁËͬÑù¶à´ÎÊýµÄÓû§/Äں˿ռäµÄÇл»(ʵ¼ÊÉϸùý³ÌÔ¶±È´Ë´¦ÃèÊöµÄÒª¸´ÔÓ£¬µ«ÊÇÎÒÏ£Íû
ÒÔ¼òµ¥µÄ·½Ê½ÃèÊöÖ®£¬ÒÔ¸üºÃµÄÀí½â±¾ÎĵÄÖ÷Ìâ)¡£
ΪÁ˸üºÃµÄÀí½âÕâÁ½¾ä´úÂëËùÉæ¼°µÄ²Ù×÷£¬Ç뿴ͼ1¡£Í¼µÄÉϰ벿չʾÁËÉÏÏÂÎÄÇл»£¬¶øÏÂ
°ë²¿Õ¹Ê¾Á˸´ÖƲÙ×÷¡£
Figure 1. Copying in Two Sample System Calls
²½ÖèÒ»£ºÏµÍ³µ÷ÓÃreadµ¼ÖÂÁË´ÓÓû§¿Õ¼äµ½Äں˿ռäµÄÉÏÏÂÎÄÇл»¡£DMAÄ£¿é´Ó´ÅÅÌÖжÁÈ¡
ÎļþÄÚÈÝ£¬²¢½«Æä´æ´¢ÔÚÄں˿ռäµÄ»º³åÇøÄÚ£¬Íê³ÉÁ˵Ú1´Î¸´ÖÆ¡£
²½Öè¶þ£ºÊý¾Ý´ÓÄں˿ռ仺³åÇø¸´ÖƵ½Óû§¿Õ¼ä»º³åÇø£¬Ö®ºóϵͳµ÷ÓÃread·µ»Ø£¬Õâµ¼ÖÂ
ÁË´ÓÄں˿ռäÏòÓû§¿Õ¼äµÄÉÏÏÂÎÄÇл»¡£´Ëʱ£¬ÐèÒªµÄÊý¾ÝÒÑ´æ·ÅÔÚÖ¸¶¨µÄÓû§¿Õ¼ä»º³å
ÇøÄÚ(²ÎÊýtmp_buf)£¬³ÌÐò¿ÉÒÔ¼ÌÐøÏÂÃæµÄ²Ù×÷¡£
²½ÖèÈý£ºÏµÍ³µ÷ÓÃwriteµ¼Ö´ÓÓû§¿Õ¼äµ½Äں˿ռäµÄÉÏÏÂÎÄÇл»¡£Êý¾Ý´ÓÓû§¿Õ¼ä»º³åÇø
±»Ôٴθ´ÖƵ½Äں˿ռ仺³åÇø£¬Íê³ÉÁ˵Ú3´Î¸´ÖÆ¡£²»¹ý£¬Õâ´ÎÊý¾Ý´æ·ÅÔÚÄں˿ռäÖÐÓëʹ
ÓõÄsocketÏà¹ØµÄÌض¨»º³åÇøÖУ¬¶ø²»ÊDz½ÖèÒ»ÖеĻº³åÇø¡£
²½ÖèËÄ£ºÏµÍ³µ÷Ó÷µ»Ø£¬µ¼ÖÂÁ˵Ú4´ÎÉÏÏÂÎÄÇл»¡£µÚ4´Î¸´ÖÆÔÚDMAÄ£¿é½«Êý¾Ý´ÓÄں˿ռä
»º³åÇø´«µÝÖÁÐÒéÒýÇæµÄÊ
Ïà¹ØÎĵµ£º
1¡¢ÏÂÔØMySQLµÄ°²×°Îļþ
°²×°MySQLÐèÒªÏÂÃæÁ½¸öÎļþ£º
MySQL-server-5.0.46.i386.rpm¡¡¡¡¡¡
MySQL-client-5.0.46.i386.rpm
2¡¢°²×°MySQL
rpmÎļþÊÇRed Hat¹«Ë¾¿ª·¢µÄÈí¼þ°²×°°ü£¬rpm¿ÉÈÃLinuxÔÚ°²×°Èí¼þ°üʱÃâ³ýÐí¶à¸´ÔÓµÄÊÖÐø¡£¸ÃÃüÁîÔÚ°²×°Ê±³£ÓõIJÎÊýÊÇ
ivh
,ÆäÖÐi±íʾ½«°²×°Ö¸¶¨µÄrmpÈí¼þ°ü£¬V±í ......
°²×°mysql
sudo apt-get install mysql-servel-5.0 mysql-client-5.0
ÏÂÔØ°²×°¹ý³ÌÖУ¬»áÌáʾÊäÈërootÃÜÂë
°²×°CÓïÑÔ±à³Ì½Ó¿Ú£º
sudo apt-get install libmysqlclient15-dev
¸ü¶àapi ²é¿´£ºhttp://dev.mysql.com/doc/refman/5.0/en/c.html
Ïà¹ØmysqlÍ·ÎļþºÍ¿âÎļþ°²×°ÔÚ/usr/include/mysql/ºÍ/usr/lib/mysqlÄ¿ ......
±¾È˳õѧlinux£¬ÔÚÁìµ¼¶½´ÙºÍ¹¤×÷ѹÁ¦Ï£¬°´ÕÕÇ°È˲¿ÊðÊÖ²áºÍÇ¿´óËÑË÷ÒýÇæ°ïÖúÏ£¬ÓÃlvsºÍmonʵÏÖµÄnat¸ºÔؾùºâ£¬vsÊÇsuse 10.2£¬realserverÊÇwindows2003µÄIIS²¿Êð¡£
1 °²×°
1.1 ÍøÂçÍØÆËͼ
1.1 ¼ì²éÄÚºËÊÇ·ñÖ§³ÖlvsÑ¡Ïî
&nbs ......
Ò»¡¢ÔÚsun¹«Ë¾ÃÅ»§ÉÏÏÂÔضÔÓ¦°æ±¾µÄjava sdk
ÎÒÏÂÔصÄÊÇjdk-6u6-linux-i586-rpm.bin°æ±¾
¶þ¡¢¸øÏÂÔØÎļþ¸³È¨ÏÞ
1¡¢Ò»°ãÐèÒªrootȨÏÞ£¬ÔÚ$Ìáʾ·ûÏÂÊäÈësu£¬È»ºóÊäÈëÃÜÂ룬¼´¿É½øÈërootģʽ¡£Ìáʾ·ûΪ#
2¡¢#chmod 755 jdk-6u6-linux-i586-rpm.bin
3¡¢#./jdk-6u6-linux-i586-rpm.bin
4¡¢#rpm -ivh jdk-6u6-linux-i586-r ......
from: http://agiser.bokee.com/viewdiary.13976981.html
ÊØ»¤½ø³Ì£¨Daemon£©ÊÇÔËÐÐÔÚºǫ́µÄÒ»ÖÖÌØÊâ½ø³Ì¡£Ëü¶ÀÁ¢ÓÚ¿ØÖÆÖն˲¢ÇÒÖÜÆÚÐÔµØÖ´ÐÐijÖÖÈÎÎñ»òµÈ´ý´¦ÀíijЩ·¢ÉúµÄʼþ¡£ÊØ»¤½ø³ÌÊÇÒ»ÖÖºÜÓÐÓõĽø
³Ì¡£
LinuxµÄ´ó¶àÊý·þÎñÆ÷¾ÍÊÇÓÃÊØ»¤½ø³ÌʵÏֵġ£±ÈÈ磬Internet·þÎñÆ÷inetd£¬Web·þÎñÆ÷httpdµÈ¡£Í¬Ê±£¬ÊØ»¤½ø³ÌÍ ......