LinuxÉ豸Çý¶¯¿ª·¢Ïê½â ±Ê¼Ç11 ÄÚ´æÓëI/O·ÃÎÊ
typedef void (*lpFunction) ();//¶¨ÒåÒ»¸öÎÞ²ÎÊý£¬ÎÞ·µ»ØÀàÐ͵ĺ¯ÊýÖ¸ÕëÀàÐÍ
//¶¨ÒåÒ»¸öº¯ÊýÖ¸Õ룬ָÏòcpuÆô¶¯ºóËùÖ´ÐеĵÚÒ»ÌõÖ¸ÁîµÄλÖÃ
lpFunction lpReset = (lpFunction)0xF000FFF0;
lpReset();//µ÷Óú¯Êý
MMUÍ£¹©ÐéÄâµØÖ·ºÍÎïÀíµØÖ·µÄÓ³Éä¡¢ÄÚ´æ·ÃÎÊȨÏÞ±£»¤ºÍCache»º´æ¿ØÖƵÈÓ²¼þÖ§³Ö¡£²Ù×÷ϵͳÄں˽èÖúMMU£¬¿ÉÒÔÈÃÓû§¸Ð¾õµ½ºÃÏñ³ÌÐò¿ÉÒÔʹÓ÷dz£´óµÄÄÚ´æ¿Õ¼ä£¬´Ó¶øʹµÃ±à³ÌÈËÔ±ÔÚд³ÌÐòʱ²»Óÿ¼ÂǼÆËã»úµÄÎïÀíÄÚ´æµÄʵ¼ÊÈÝÁ¿
Èçͼ£¬µ±ARMÒª·ÃÎÊ´æ´¢Æ÷ʱ£¬MMUÏȲéÕÒTLBÖеÄÐéÄâµØÖ·±í¡£Èç¹ûARMµÄ½á¹¹Ö§³Ö·Ö¿ªµÄÊý¾ÝTLB£¨DTLB£©ºÍÖ¸ÁîTLB£¨ITLB£©£¬Ôò³ýÈ¥Ö¸ÁîʹÓõÄITLBÍ⣬ÆäËûµÄ¶¼ÊÇÓÃDTLB
ÈôTLBÖÐûÓÐÐéÄâµØÖ·µÄÈë¿Ú£¬Ôòת»»±í±éÀúÓ²¼þ´Ó´æ·ÅÓÚÖ÷´æ´¢Æ÷ÖеÄת»»±íÖлñÈ¡µØַת»»ÐÅÏ¢ºÍ·ÃÎÊȨÏÞ£¨¼´Ö´ÐÐTTW£©£¬Í¬Ê±½«ÕâЩÐÅÏ¢·ÅÈëTLB£¬Ëü»òÕß±»·ÅÔÚÒ»¸öûÓÐʹÓõÄÈë¿Ú»òÕßÌæ»»Ò»¸öÒѾ´æÔÚµÄÈë¿Ú¡£Ö®ºó£¬ÔÚTLBÌõÄ¿ÖпØÖÆÐÅÏ¢µÄ¿ØÖÆÏ£¬µ±·ÃÎÊȨÏÞÔÊÐíʱ£¬¶ÔÕæʵÎïÀíµØÖ·µÄ·ÃÎʽ«ÔÚCache»òÕßÔÚÄÚ´æÖз¢Éú
Óû§¿Õ¼ä0-3GB£¬Äں˿ռä3-4GB£¬Óû§½ø³Ìͨ³£Çé¿öÏÂÖ»ÄÜ·ÃÎÊÓû§¿Õ¼äµÄÐéÄâµØÖ·£¬²»ÄÜ·ÃÎÊÄں˿ռäÐéÄâµØÖ·¡£Óû§½ø³ÌÖ»ÄÜͨ¹ýϵͳµ÷Óõȷ½Ê½²ÅÄÜ·ÃÎʵ½Äں˿ռä
ÿ¸ö½ø³ÌµÄÓû§¿Õ¼ä¶¼ÊÇÍêÈ«¶ÀÁ¢¡¢»¥²»Ïà¸ÉµÄ£¬Óû§½ø³Ì¸÷×ÔÓв»Í¬µÄÒ³±í¡£¶øÄں˿ռäÊÇÓÉÄں˸ºÔðÓ³É䣬Ëü²¢²»»á¸ú׎ø³Ì¸Ä±ä£¬Êǹ̶¨µÄ¡£Äں˿ռäµØÖ·ÓÐ×Ô¼º¶ÔÓ¦µÄÒ¶±í£¬Äں˵ÄÐéÄâ¿Õ¼ä¶ÀÁ¢ÓÚÆäËû³ÌÐò
LinuxÖеÄ1GBÄں˵ØÖ·¿Õ¼äÓÖ±»»®·ÖΪÄÚ´æÓ³ÉäÇø£¬ÐéÄâÄÚ´æ·ÖÅäÇø¡¢¸ß¶ËÒ³ÃæÓ³ÉäÇø¡¢×¨ÓÃÒ³ÃæÓ³ÉäÇøºÍϵͳ±£ÁôÓ³ÉäÇø
void kmalloc(size_t size, int flags);
µÚ¶þ¸ö²ÎÊýΪ·ÖÅä±êÖ¾£¬ÓÃÓÚ¿ØÖÆkmallocµÄÐÐΪ£¬×îͨ³£ÓõķÖÅä±êÖ¾ÊÇGFP_KERNEL£¬Æ京ÒåÊÇÔÙÄں˿ռäµÄ½ø³ÌÖÐÉêÇëÄÚ´æ¡£KmallocµÄµ×²ãÒÀÀµ__get_free_pages()ʵÏÖ£¬GFPÕýºÃÊÇÕâ¸öº¯ÊýµÄËõд£¬Ê¹ÓÃGFP_KERNEL±êÖ¾ÉêÇëÄÚ´æʱ£¬ÈôÔÝʱ²»ÄÜÂú×㣬Ôò½ø³Ì»á˯ÃߵȴýÒ³£¬¼´ÒýÆð×èÈû£¬Òò´Ë²»ÄÜÔÚÖжÏÉÏÏÂÎÄ»ò³ÖÓÐ×ÔÐýËøµÄʱºòʹÓô˱êÖ¾ÉêÇëÄÚ´æ
ÔÚÖжϴ¦Àíº¯Êý¡¢taskletºÍÄں˶¨Ê±Æ÷µÈ·Ç½ø³ÌÉÏÏÂÎÄÖв»ÄÜ×èÈû£¬´ËʱÇý¶¯Ó¦¸ÃʹÓÃGFP_ATOMIC±êÖ¾À´ÉêÇ룬Èô²»´æÔÚ¿ÕÏÐÒ³£¬Ö±½Ó·µ»Ø
__get_free_pages()£º
´ËϵÁк¯Êý°üÀ¨£º
get_zeroed_page(unsigned int flags)£»
·µ»ØÒ»¸öÖ¸ÏòÐÂÒ³µÄÖ¸Õë²¢ÇÒ½«¸ÃÒ³ÇåÁã
__get_free_page(unsigned int flags)
¸Ãºê·µ»ØÒ»
Ïà¹ØÎĵµ£º
´Ówrite()µ÷Ó÷µ»Øʱ£¬ÄÚºËÒѾ½«»º³åÇøËùÌṩµÄÊý¾Ýµ½Äں˵Ļº³åÇø£¬µ«ÊÇÎÞ·¨±£Ö¤Êý¾ÝÒѾд³öµ½ÆäÔ¤¶¨µÄÄ¿µÄµØ¡£µÄÈ·£¬Ð´Èëµ÷Ó÷µ»ØµÄËÙ¶ÈʵÔÚÌ«¿ìÁË£¬¿ÉÄÜûÓÐʱ¼äÍê³É¸ÃÏîÄ¿µÄ¹¤×÷¡£´¦ÀíÆ÷ºÍÓ²ÅÌÖ®¼äµÄÐÔÄܲîÒìʹµÃ´ËÀàÁîÈËÍ·Í´µÄÐÐΪÏÔ¶øÒ×¼û¡£
ÊÂʵÉÏ£¬Èç¹ûÓû§¿Õ¼äÓ¦ÓóÌÐò·¢³öwrite()ϵͳµ÷Óã¬LinuxÄں˻áÏȽøÐÐÈ ......
ÔÚÓû§¿Õ¼ä£¬Ê¹ÓÃioctlϵͳµ÷ÓÃÀ´¿ØÖÆÉ豸£¬ÔÐÍÈçÏ£º
int ioctl(int fd, unsigned long cmd, ...);
µÚÈý¸ö²ÎÊý²»±íʾһ¸ö±äÊýÄ¿µÄ²ÎÊý£¬¶øÊÇÒ»¸öÀàÐÍ¿ÉÑ¡µÄ²ÎÊý¡£µÚÈý¸ö²ÎÊýÒÀÀµÓÚ¿ØÖÆÃüÁһЩÃüÁî²»ÓòÎÊý£¬Ò»Ð©ÓÃÒ»¸öÕûÊýÖµ£¬Ò»Ð©Ê¹ÓÃÖ¸Õë
1¡¢ioctlº¯Êý¶¨ÒåÃüÁî
ÔÚ±àдioctl´úÂë֮ǰ£¬Ê×ÏÈÐèÒª¶¨ÒåÃüÁΪÁË·ÀÖ¹ ......
ʲôÊÇÇý¶¯£¿
×îͨË׵ĽâÊ;ÍÊÇ“ÇýʹӲ¼þÉ豸Ðж¯”
×÷Óã¿
É豸Çý¶¯Óëµ×²ãÓ²¼þÖ±½Ó´ò½»µÀ£¬°´ÕÕÓ²¼þÉ豸µÄ¾ßÌ幤×÷·½Ê½¶ÁдÉ豸¼Ä´æÆ÷£¬Íê³ÉÉ豸µÄÂÖѯ¡¢Öжϴ¦Àí¡¢DMAͨÐÅ£¬½øÐÐÎïÀíÄÚ´æÏòÐéÄâÄÚ´æµÄÓ³É䣬×îÖÕʹͨÐÅÉ豸Äܹ»ÊÕ·¢Êý¾Ý£¬Ê¹ÏÔʾÉ豸Äܹ»ÏÔʾÎÄ×ֺͻÃ棬ʹ´æ´¢É豸Äܹ»¼Ç¼ÎļþºÅÊý¾Ý
¼ÆË ......
ÎҵĵÚÒ»¸öshell³ÌÐò£ºtt1.sh
while true
do
date;
sleep 1;
done
Ö´Ðз½Ê½1£ºsh tt1.sh
Ö´Ðз½Ê½2£º./tt1.sh£¨ÒªÇó¸ÃÎļþÓпÉÖ´ÐÐȨÏÞ£©
Shell±äÁ¿£º
»·¾³±äÁ¿£º
¹¤¾ß£ºecho »ØÏÔ
&n ......
select()º¯ÊýµÄ×÷ÓÃ
ϵͳµ÷ÓÃselectºÍpollµÄºó¶ËʵÏÖ£¬ÓÃÕâÁ½¸öϵͳµ÷ÓÃÀ´²éѯÉ豸ÊÇ·ñ¿É¶Áд£¬»òÊÇ·ñ´¦ÓÚijÖÖ״̬¡£Èç¹ûpollΪ¿Õ£¬ÔòÇý¶¯É豸»á±»ÈÏΪ¼´¿É¶ÁÓÖ¿Éд£¬·µ»ØÖµÊÇÒ»¸ö״̬ÑÚÂë
ÈçºÎʹÓÃselect()º¯Êý?
select()º¯ÊýµÄ½Ó¿ÚÖ÷ÒªÊǽ¨Á¢ÔÚÒ»ÖÖ½Ð'fd_set'ÀàÐ͵Ļù´¡ÉÏ¡£Ëü( ......