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

linux¶ÁдÎļþËٶȲâÊÔ

Ò». ÎļþÒ»´Î¶ÁÈëËÙ¶È
linux϶ÁÎļþÕⶫÎ÷×îºó¶¼ÊÇҪͨ¹ýϵͳµ÷ÓÃsys_read(fd,buf,count)À´ÊµÏֵģ¬ËùÒÔÈç¹ûÒªÌá¸ßËٶȣ¬¾ÍÊÇ×î¼òµ¥µØµ÷ÓÃsys_readµÄ·â×°£¬±ÈÈçÖ±½ÓÓÃread()»òfread()¡£ÏÂÃæÊÇÎÒÔÚlinuxϵļ¸¸ö²âÊÔ¡£
Ê×ÏÈ´´½¨Ò»¸ö130MÊý¾ÝÎļþ dd if=/dev/zero of=data bs=1024k count=130
[dd if=/dev/zero of=data bs=1024k count=130 ת»»ºÍ¿½±´Îļþ£¬´ÓÊäÈëifµÄÔ´ÍùofµÄÄ¿µÄµØÖ·¿½±´£¬Ã¿¸öblock1024k£¬Ò»¹²¿½±´130¸ö¡£]
·Ö±ðÓÃfread,readºÍfgetsÒ»´Î¶ÁÈëÈ«²¿´óСÎļþËùÏûºÄʱ¼ä¶Ô±È,ÆäÖÐ
size=130*1024*1024
char *buf=new char[size];
ÏÂÃæÊDzâÊÔ½á¹û(»úÆ÷Intel(R) Pentium(R) 4 CPU 3.20GHz, Mem 1G):
1.fread(buf,size,1,fp)Ò»´Î¶ÁÈë
real    0m0.187s
user    0m0.000s
sys     0m0.180s
2.read(fdin,(void *)buf,size)Ò»´Î¶ÁÈë
real    0m0.187s
user    0m0.000s
sys     0m0.184s
3.¶à´Îfgets(buf,size,fp),ÿ´Î1k
real    0m0.356s
user    0m0.136s
sys     0m0.220s
4.fgets(buf,size,fp)Ò»´Î¶ÁÈë
real    0m0.305s
user    0m0.072s
sys     0m0.232s
ÉÏÃæ¿´µ½Ô½¼òµ¥µÄº¯Êý(read()ºÍfread())£¬ËÙ¶ÈÔ½¿ì£¬ÆäËûµÄÊäÈë·â×°º¯ÊýÖ»²»¹ýÊÇΪÁË·½±ãÂú×ãÌØÊâÐèÒª£¬²¢²»¼ûµÃ¶ÁµÄËٶȻáºÜ¿ì¡£¶ÔÓÚ3ºÍ 4,ÒòΪÔÚsys_read()ÄÚ²¿ÓжԶÁÈë´óСµÄÅжϺÍwhileÑ­»·£¬ËùÒÔ´óÎļþ¶ÁȡҲû±ØÒªÏñ3ÄÇÑù·Ö¶à´Îµ÷ÓÃfgets()À´¶ÁÎļþ.
ÁíÍâÓÃmmap()ÄÚ´æÓ³ÉäÀ´¶ÁÈëÎļþµÄʱ¼äÈçÏÂ:
real    0m0.231s
user    0m0.068s
sys     0m0.164s
Ò²²¢Ã»ÓбÈÖ±½Óread()¿ì£¬ÍøÉÏÕÒµ½Ò»ÖÖ½âÊÍÊǶÔÓÚÐèҪƵ·±¶Áд²Ù×÷µÄ£¬mmapЧÂʲŻáÏÔÖøÌá¸ß¡£ÏÂÃæÀ´Ä£ÄâƵ·±¶Áд²Ù×÷¡£
¶þ. ÎļþƵ·±¶ÁдËٶȲâÊÔ
1. ÕâÒ»¸ö²âÊÔÄ£ÄâƵ·±Îļþ¶Áд²Ù×÷£¬500M´óСµÄÊý¾ÝÎļþdata.in£¬Ã¿´Î´ÓÖжÁÈë1k¸ö×Ö½Ú¶Ôÿ¸ö×Ö½Ú×ö¼Ó1¼òµ¥¼ÆË㣬ÔÙдµ½ÁíÒ»¸öÎļþdata.outÖС£
//mmapx1.c
#define size 1024*1024*500
#define LEN 1024
#include <stdio.h>
int main()
{
    FILE *fp1,*fp2;
    char *buf=new char[LEN];
    int i,j;
&nb


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

Linux ±àÒë°²×° MYSQL 5.1 Óë Innodb

Linux ±àÒë°²×° MYSQL 5.1 Óë Innodb
±àÒëmysql5
´úÂë:
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-extra-charsets=all \
--with-charset=utf8 \
- ......

ǶÈëʽlinuxϵͳÓëÓ¦ÓÃ

Emebedded System and Application(Linux)
 
Goal
--
ÕÆÎÕǶÈëʽϵͳ¿ª·¢µÄÁ÷³Ì£¬ÏµÍ³ÒÆÖ²µÄ·½·¨£¬±àдBootloader
            (Be familiar with the process of ES Developing
, System Migration
amd Bootloader Programming
)
 Requriem ......

Linux LVM µÄʹÓÃÏê½â

Linux LVM µÄʹÓÃÏê½â
http://blog.csdn.net/icejadelove/archive/2009/10/30/4747657.aspx
ÕªÒª£ºLinuxÓû§°²×°Linux²Ù×÷ϵͳʱÓöµ½µÄÒ»¸ö×î³£¼ûµÄÄÑÒÔ¾ö¶¨µÄÎÊÌâ¾ÍÊÇÈçºÎÕýÈ·µØ¸øÆÀ¹À¸÷·ÖÇø´óС£¬ÒÔ·ÖÅäºÏÊʵÄÓ²Å̿ռ䡣¶øÓöµ½³öÏÖij¸ö·ÖÇø¿Õ¼äºÄ¾¡Ê±£¬½â¾öµÄ·½·¨Í¨³£ÊÇʹÓ÷ûºÅÁ´½Ó£¬»òÕßʹÓõ÷Õû·ÖÇø´óСµÄ¹¤¾ß(±ÈÈçP ......

Linux LVM µÄʹÓÃÏê½â

welcome Linux LVM µÄʹÓÃÏê½â ÕªÒª£ºLinuxÓû§°²×°Linux²Ù×÷ϵͳʱÓöµ½µÄÒ»¸ö×î³£¼ûµÄÄÑÒÔ¾ö¶¨µÄÎÊÌâ¾ÍÊÇÈçºÎÕýÈ·µØ¸øÆÀ¹À¸÷·ÖÇø´óС£¬ÒÔ·ÖÅäºÏÊʵÄÓ²Å̿ռ䡣¶øÓöµ½³öÏÖij¸ö·ÖÇø¿Õ¼äºÄ¾¡Ê±£¬½â¾öµÄ·½·¨Í¨³£ÊÇʹÓ÷ûºÅÁ´½Ó£¬»òÕßʹÓõ÷Õû·ÖÇø´óСµÄ¹¤¾ß(±ÈÈçPatition MagicµÈ)£¬µ«ÕⶼֻÊÇÔÝʱ½â¾ö°ì·¨£¬Ã»Óиù±¾½â¾öÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ