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

LinuxÄÚºËMakefiledzÎö£¨×ª


1£® ÅäÖÃϵͳµÄ»ù±¾½á¹¹
LinuxÄں˵ÄÅäÖÃϵͳÓÉÈý¸ö²¿·Ö×é³É£¬·Ö±ðÊÇ£º
Makefile£º·Ö²¼ÔÚ Linux ÄÚºËÔ´´úÂëÖÐµÄ Makefile£¬¶¨Òå Linux Äں˵ıàÒë¹æÔò£»
ÅäÖÃÎļþ£¨config.in£©£º¸øÓû§ÌṩÅäÖÃÑ¡ÔñµÄ¹¦ÄÜ£»
ÅäÖù¤¾ß£º°üÀ¨ÅäÖÃÃüÁî½âÊÍÆ÷£¨¶ÔÅäÖýű¾ÖÐʹÓõÄÅäÖÃÃüÁî½øÐнâÊÍ£©ºÍÅäÖÃÓû§½çÃ棨Ìṩ»ùÓÚ×Ö·û½çÃæ¡¢»ùÓÚ Ncurses ͼÐνçÃæÒÔ¼°»ùÓÚ Xwindows ͼÐνçÃæµÄÓû§ÅäÖýçÃ棬¸÷×Ô¶ÔÓ¦ÓÚ Make config¡¢Make menuconfig ºÍ make xconfig£©¡£
ÕâЩÅäÖù¤¾ß¶¼ÊÇʹÓýű¾ÓïÑÔ£¬Èç Tcl/TK¡¢Perl ±àдµÄ£¨Ò²°üº¬Ò»Ð©Óà C ±àдµÄ´úÂ룩¡£±¾ÎIJ¢²»ÊǶÔÅäÖÃϵͳ±¾Éí½øÐзÖÎö£¬¶øÊǽéÉÜÈçºÎʹÓÃÅäÖÃϵͳ¡£ËùÒÔ£¬³ý·ÇÊÇÅäÖÃϵͳµÄά»¤Õߣ¬Ò»°ãµÄÄں˿ª·¢ÕßÎÞÐëÁ˽âËüÃǵÄÔ­Àí£¬Ö»ÐèÒªÖªµÀÈçºÎ±àд Makefile ºÍÅäÖÃÎļþ¾Í¿ÉÒÔ¡£ËùÒÔ£¬ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÖ»¶Ô Makefile ºÍÅäÖÃÎļþ½øÐÐÌÖÂÛ¡£ÁíÍ⣬·²ÊÇÉæ¼°µ½Óë¾ßÌå CPU Ìåϵ½á¹¹Ïà¹ØµÄÄÚÈÝ£¬ÎÒÃǶ¼ÒÔ ARM ΪÀý£¬ÕâÑù²»½ö¿ÉÒÔ½«ÌÖÂÛµÄÎÊÌâÃ÷È·»¯£¬¶øÇÒ¶ÔÄÚÈݱ¾Éí²»²úÉúÓ°Ïì¡£
2£® Makefile
2.1 Makefile ¸ÅÊö
Makefile µÄ×÷ÓÃÊǸù¾ÝÅäÖõÄÇé¿ö£¬¹¹Ôì³öÐèÒª±àÒëµÄÔ´ÎļþÁÐ±í£¬È»ºó·Ö±ð±àÒ룬²¢°ÑÄ¿±ê´úÂëÁ´½Óµ½Ò»Æð£¬×îÖÕÐÎ³É Linux Äں˶þ½øÖÆÎļþ¡£
ÓÉÓÚ Linux ÄÚºËÔ´´úÂëÊÇ°´ÕÕÊ÷Ðνṹ×éÖ¯µÄ£¬ËùÒÔ Makefile Ò²±»·Ö²¼ÔÚĿ¼Ê÷ÖС£Linux ÄÚºËÖÐµÄ Makefile ÒÔ¼°Óë Makefile Ö±½ÓÏà¹ØµÄÎļþÓУº
Makefile£º¶¥²ã Makefile£¬ÊÇÕû¸öÄÚºËÅäÖᢱàÒëµÄ×ÜÌå¿ØÖÆÎļþ¡£
.config£ºÄÚºËÅäÖÃÎļþ£¬°üº¬ÓÉÓû§Ñ¡ÔñµÄÅäÖÃÑ¡ÏÓÃÀ´´æ·ÅÄÚºËÅäÖúóµÄ½á¹û£¨Èç make config£©¡£
arch/*/Makefile£ºÎ»ÓÚ¸÷ÖÖ CPU ÌåϵĿ¼Ï嵀 Makefile£¬Èç arch/arm/Makefile£¬ÊÇÕë¶ÔÌض¨Æ½Ì¨µÄ Makefile¡£
¸÷¸ö×ÓĿ¼Ï嵀 Makefile£º±ÈÈç drivers/Makefile£¬¸ºÔðËùÔÚ×ÓĿ¼ÏÂÔ´´úÂëµÄ¹ÜÀí¡£
Rules.make£º¹æÔòÎļþ£¬±»ËùÓÐµÄ Makefile ʹÓá£
Óû§Í¨¹ý make config ÅäÖú󣬲úÉúÁË .config¡£¶¥²ã Makefile ¶ÁÈë .config ÖеÄÅäÖÃÑ¡Ôñ¡£¶¥²ã Makefile ÓÐÁ½¸öÖ÷ÒªµÄÈÎÎñ£º²úÉú vmlinux ÎļþºÍÄÚºËÄ£¿é£¨module£©¡£ÎªÁË´ïµ½´ËÄ¿µÄ£¬¶¥²ã Makefile µÝ¹éµÄ½øÈëµ½Äں˵ĸ÷¸ö×ÓĿ¼ÖУ¬·Ö±ðµ÷ÓÃλÓÚÕâЩ×ÓĿ¼ÖÐµÄ Makefile¡£ÖÁÓÚµ½µ×½øÈëÄÄЩ×ÓĿ¼£¬È¡¾öÓÚÄں˵ÄÅäÖá£ÔÚ¶¥²ã Makefile ÖУ¬ÓÐÒ»¾ä£ºinclude arch/$(ARCH)/Makefile£¬°üº¬ÁËÌض¨ CPU Ìåϵ½á¹¹Ï嵀 Makefile£¬Õâ¸ö Makefile Öаüº¬ÁËƽ̨Ïà¹ØµÄÐÅÏ¢¡£
λÓÚ¸÷¸


Ïà¹ØÎĵµ£º

¼òµ¥µÄLinux·þÎñÆ÷¼à¿Ø½Å±¾

#!/bin/bash
cpu=`top -b -n 1 | grep -w Cpu | awk '{print$5}'| awk -F '%' '{printf"%d",$1}'`
if [ $cpu -le 50 ]
then
echo "cpu: $((100 - cpu))%" > test.txt
mail -s "·þÎñÆ÷½ô¼±, CPUÕ¼ÓÃÂʹý¸ß£¡" yourmail@domail.com < test.txt
fi
mem=`top -b -n 1 | grep -w Me ......

Linux 2.6 ×Ö·ûÉ豸Çý¶¯³ÌÐò

˵Ã÷
±Ê¼ÇÊÊÓÃÓÚLinuxµÄ2.6.10ÒÔºóµÄÄںˡ£
±Ê¼ÇÒÔLinux
Device
Driver3ÌṩµÄscull³ÌÐò(scullĿ¼ÖеÄmain.cºÍscull.h)Ϊ¼Ç¼Ö÷Ïߣ¬²¢ÒÔ¸ÃÇý¶¯³ÌÐòÖеĸ÷ÖÖϵͳµ÷Óúͺ¯Êýµ÷ÓÃÁ÷³ÌΪ¼Ç
¼˳Ðò¡£±ÈÈ磬module_init( )ºÍmodule_exit(
)ΪÏà¶ÔÓ¦µÄÒ»¶Ôϵͳµ÷Óã¬Ò»°ãÊé¼®Öж¼»á·ÅÔÚÒ»ÆðÌÖÂÛ£¬µ«ÊDZ¾±Ê¼ÇÈ´²»»áÕâÑù£¬¶øÊ ......

linux»ñȡϵͳʱ¼ä

1.ʱ¼ä±íʾ
ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ­³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û¡£Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý
time_t time(time_t *tloc);                    //ʱ¼ä¾«¶ÈΪÃë
char *ctime(const time_ ......

Linux×Ö·ûÉ豸Çý¶¯³ÌÐò¿ª·¢

LinuxϵÄÉ豸Çý¶¯³ÌÐò±»×é֯Ϊһ×éÍê³É²»Í¬ÈÎÎñµÄº¯ÊýµÄ¼¯ºÏ£¬Í¨¹ýÕâЩº¯ÊýʹµÃWindowsµÄÉ豸²Ù×÷ÓÌÈçÎļþÒ»°ã¡£ÔÚÓ¦ÓóÌÐò¿´À´£¬Ó²¼þÉ豸ֻÊÇÒ»¸öÉ豸Îļþ£¬Ó¦ÓóÌÐò¿ÉÒÔÏó²Ù×÷ÆÕͨÎļþÒ»Ñù¶ÔÓ²¼þÉ豸½øÐвÙ×÷£¬Èçopen ()¡¢close ()¡¢read ()¡¢write () µÈ¡£
LinuxÖ÷Òª½«É豸·ÖΪ¶þÀࣺ×Ö·ûÉ豸ºÍ¿éÉ豸¡£×Ö·ûÉ豸ÊÇÖ¸Éè ......

linuxÉÏcÓïÑÔ »ñµÃÍøÂç½Ó¿ÚµÄͳ¼ÆÖµ

Õâ¸ö¶«¶«£¬ÂùºÃÍæµÄ¡£Æäʵ¾ÍÊǶÁÈ¡ÁË/proc/net/dev Îļþ¡£
struct netdev_stats {
    unsigned long long rx_packets_m;    /* total packets received       */
    unsigned long long tx_packets_m;     &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ