linux topÃüÁîÏê½â
topÃüÁîÊÇLinuxϳ£ÓõÄÐÔÄÜ·ÖÎö¹¤¾ß£¬Äܹ»ÊµÊ±ÏÔʾϵͳÖи÷¸ö½ø³ÌµÄ×ÊÔ´Õ¼ÓÃ×´¿ö£¬ÀàËÆÓÚWindowsµÄÈÎÎñ¹ÜÀíÆ÷¡£ÏÂÃæÏêϸ½éÉÜËüµÄʹÓ÷½·¨¡£
top - 01:06:48 up 1:22, 1 user, load average: 0.06, 0.60, 0.48
Tasks: 29 total, 1 running, 28 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% us, 1.0% sy, 0.0% ni, 98.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 191272k total, 173656k used, 17616k free, 22052k buffers
Swap: 192772k total, 0k used, 192772k free, 123988k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1379 root 16 0 7976 2456 1980 S 0.7 1.3 0:11.03 sshd
14704 root 16 0 2128 980 796 R 0.7 0.5 0:02.72 top
1 root 16 0 1992 632 544 S 0.0 0.3 0:00.90 init
2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
ͳ¼ÆÐÅÏ¢Çø
Ç°ÎåÐÐÊÇϵͳÕûÌåµÄͳ¼ÆÐÅÏ¢¡£µÚÒ»ÐÐÊÇÈÎÎñ¶ÓÁÐÐÅÏ¢£¬Í¬ uptime ÃüÁîµÄÖ´Ðнá¹û¡£ÆäÄÚÈÝÈçÏ£º
01:06:48 µ±Ç°Ê±¼ä
up 1:22 ϵͳÔËÐÐʱ¼ä£¬¸ñʽΪʱ:·Ö
1 user µ±Ç°µÇ¼Óû§Êý
load average: 0.06, 0.60, 0.48 ϵͳ¸ºÔØ£¬¼´ÈÎÎñ¶ÓÁеÄƽ¾ù³¤¶È¡£
Èý¸öÊýÖµ·Ö±ðΪ 1·ÖÖÓ¡¢5·ÖÖÓ¡¢15·ÖÖÓÇ°µ½ÏÖÔÚµÄƽ¾ùÖµ¡£
µÚ¶þ¡¢ÈýÐÐΪ½ø³ÌºÍCPUµÄÐÅÏ¢¡£µ±Óжà¸öCPUʱ£¬ÕâЩÄÚÈÝ¿ÉÄܻᳬ¹ýÁ½ÐС£ÄÚÈÝÈçÏ£º
Tasks: 29 total ½ø³Ì×ÜÊý
1 running ÕýÔÚÔËÐеĽø³ÌÊý
28 sleeping ˯ÃߵĽø³ÌÊý
0 stopped Í£Ö¹µÄ½ø³ÌÊý
0 zombie ½©Ê¬½ø³ÌÊý
Cpu(s): 0.3% us Óû§¿Õ¼äÕ¼ÓÃCPU°Ù·Ö±È
1.0% sy Äں˿ռäÕ¼ÓÃCPU°Ù·Ö±È
0.0% ni Óû§½ø³Ì¿Õ¼äÄڸıä¹ýÓÅÏȼ¶µÄ½ø³ÌÕ¼ÓÃCPU°Ù·Ö±È
98.7% id ¿ÕÏÐCPU°Ù·Ö±È
0.0% wa µÈ´ýÊäÈëÊä³öµÄCPUʱ¼ä°Ù·Ö±È
0.0% hi
0.0% si
×îºóÁ½ÐÐΪÄÚ´æÐÅÏ¢¡£ÄÚÈÝÈçÏ£º
Mem: 191272k total ÎïÀíÄÚ´æ×ÜÁ¿
173656k used ʹÓõÄÎïÀíÄÚ´æ×ÜÁ¿
17616k free ¿ÕÏÐÄÚ´æ×ÜÁ¿
22052k buffers ÓÃ×÷Äں˻º´æµÄÄÚ´æÁ¿
Swap: 192772k total ½»»»Çø×ÜÁ¿
0k used ʹÓõĽ»»»Çø×ÜÁ¿
192772k free ¿ÕÏн»»»Çø×ÜÁ¿
123988k cached »º³åµÄ½»»»Çø×ÜÁ¿¡£
ÄÚ´æÖеÄÄÚÈݱ»»»³öµ½½»»»Çø£¬¶øºóÓÖ±»»»Èëµ½Äڴ棬µ«Ê¹ÓùýµÄ½»»»ÇøÉÐδ±»¸²¸Ç£¬
¸ÃÊýÖµ¼´ÎªÕâЩÄÚÈÝÒÑ´æÔÚÓÚÄÚ´æÖеĽ»»»ÇøµÄ´óС¡£
ÏàÓ¦µÄÄÚ´æÔٴα»»»³öʱ¿É²»±ØÔÙ¶Ô½»»»ÇøдÈë¡£
½ø³
Ïà¹ØÎĵµ£º
#apt-get install gcc (±àÒëÆ÷)
#apt-get install gdb (µ÷ÊÔ)
#apt-get install libc6-dev (¿ª·¢¿â)
Èç¹ûûÓпª·¢¿â£¬gccµÄʱºò¾Í»á´íÎó
gcc h.c
h.c: In function ‘main’:
h.c:1: warning: incompatible implicit declaration of built-in function ‘prin ......
ΪÄÚºËÑ°ÕÒнø³ÌÔÚcpuÉÏÔËÐÐʱ£¬±ØÐëÖ»¿¼ÂÇ¿ÉÔËÐнø³Ì£¨TASK_RUNNING£©¡£
Ìá¸ßµ÷¶È³ÌÐòÔËÐÐËٶȵľ÷ÇÏÊǽ¨Á¢¶à¸ö¿ÉÔËÐнø³ÌÁ´±í£¬Ã¿ÖÖ½ø³ÌÓÅÏÈȨ¶ÔÓ¦Ò»¸ö²»Í¬µÄÁ´±í¡£Ã¿¸ötask_structÃèÊö·û°üº¬Ò»¸ölist_headÀàÐ͵Ä×Ö¶Îrun_list¡£Èç¹û½ø³ÌµÄÓÅÏÈȨµÈÓÚk(0-139)£¬run_list×ֶΰѸýø³ÌÁ´ÈëÓÅÏÈȨΪkµÄ¿ÉÔËÐнø³ÌµÄÁ´±íÖС£ ......
É¢ÁУ¨hash£©º¯Êý²¢²»×ÜÄÜÈ·±£pidÓë±íË÷ÒýÒ»Ò»¶ÔÓ¦¡£Á½¸ö²»Í¬µÄpidÉ¢Áе½ÏàͬµÄ±íË÷Òý³ÆΪ³åÍ»£¨colliding£©,linuxÀûÓÃÁ´±íÀ´´¦Àí³åÍ»µÄpid,ÿһ¸ö±íÏîÊÇÓɳåÍ»µÄ½ø³ÌÃèÊö·û×é³ÉµÄË«ÏòÁ´±í¡£
pidÉ¢ÁбíµÄÊý¾Ý½á¹¹½â¾öÁËËùÓÐÕâЩÄÑÌ⣬ËûÃÇ¿ÉÒÔΪ°üº¬ÔÚÒ»¸öÉ¢ÁбíÖеÄÈκÎpidºÅ¶¨Òå½ø³ÌÁ´±í¡£×îÖ÷ÒªµÄÊý¾Ý½á¹¹ÊÇËĸöpid½á ......
linux Äں˷ÖÎöÖ®list_head
±¾ÎÄÏêϸ·ÖÎöÁË 2.6.x ÄÚºËÖÐÁ´±í½á¹¹µÄʵÏÖ£¬²¢Í¨¹ýʵÀý¶Ôÿ¸öÁ´±í²Ù×÷½Ó¿Ú½øÐÐÁËÏ꾡µÄ½²½â¡£
Ò»¡¢ Á´±íÊý¾Ý½á¹¹¼ò½é
Á´±íÊÇÒ»ÖÖ³£ÓõÄ×éÖ¯ÓÐÐòÊý¾ÝµÄÊý¾Ý½á¹¹£¬Ëüͨ¹ýÖ¸Õ뽫һϵÁÐÊý¾Ý½ÚµãÁ¬½Ó³ÉÒ»ÌõÊý¾ÝÁ´£¬ÊÇÏßÐÔ±íµÄÒ»ÖÖÖØҪʵÏÖ·½Ê½¡£Ïà¶ÔÓÚÊý×飬Á´±í¾ßÓиüºÃµÄ¶¯Ì¬Ð ......