ǶÈëʽLinuxÎïÀíÄÚ´æÓ³Éä
The physical memory map for Linux is completely independent from the virtual map and is designed to maximize contiguous space. Given that the kernel image will always be at the start of DRAM, the Linux kernel maximizes contiguous space by allocating runtime memory from the end of physical DRAM moving downward.
The kernel starts by breaking available memory out into large, contiguous blocks (typically 4MB or more).It then maintains memory using the buddy system, where physical memory is always allocated in combinations of blocks of 2^n pages (where n is the order, that is, 4K is a 0 order block, 8K is a 1st order block, 16K is a 2nd order block, etc).
LinuxÎïÀíÄÚ´æµÄÓ³ÉäÍêÈ«¶ÀÁ¢ÓÚÐéÄâÄÚ´æµÄÓ³É䣬¶øÇÒ¾¡¿ÉÄÜÓ³Éäµ½Á¬ÐøµÄ¿Õ¼ä¡£¼Ù¶¨ÄÚºËÓ³Ïñ×ÜÊÇλÓÚDRAMµÄ¿ªÊ¼´¦£¬LinuxÄں˾¡¿ÉÄÜÈÿռäÁ¬Ðø£¬ÕâÊÇͨ¹ý´ÓÎïÀíDRAMµÄÄ©¶ËÏòÏÂÒÆ¶¯À´·ÖÅäÔËÐÐʱÄÚ´æ¶ø´ïµ½µÄ¡£
ÄÚºËÒ»¿ªÊ¼°Ñ¿ÉÓÃÄÚ´æ·Ö¸îΪ´ó¶øÁ¬ÐøµÄ¿é£¨Í¨³£Îª4MB »ò¸ü¶à£©¡£´Ëºó£¬ÄÚºËÀûÓûï°éËã·¨À´¹ÜÀíÄڴ棬ÕâÀÎïÀíÄÚ´æµÄ·ÖÅä×ÜÊÇ2^n¸öÒ³ËùÐγɿéµÄ×éºÏ£¨ÕâÀnÊÇÃÝ£¬4k¾ÍÊÇÃÝΪ0µÄ¿é£¬8KÊÇÃÝΪ1¿é£¬16KΪÃÝΪ2µÄ¿é£¬Èç´ËµÈµÈ£©¡£
When physical memory is allocated, that is, on process start, or when malloc’ed memory is written to (copy-on-write), the kernel scans for the smallest order block that will fill fit starting from the top of DRAM. As the number of running processes increases, or new allocations are spawned from drivers or processes, the physical memory used grows downward.
µ±ÎïÀíÄÚ´æ·ÖÅäʱ£¬Ò²¾ÍÊÇÔÚ½ø³Ì¸Õ¿ªÊ¼Ê±£¬»òÕß˵µ±·ÖÅäµÄÄڴ汻дÈëʱ£¨Ð´Ê±¸´ÖÆ£©£¬ÄÚºËɨÃè×îСÃݴεĿ飨´ÓDRAM¶¥²¿¿ªÊ¼Ñ°ÕÒ×îºÏÊʵģ©¡£Ëæ×Žø³ÌÊýµÄÔö¼Ó£¬»òÕßÀ´×ÔÇý¶¯³ÌÐò»ò½ø³ÌзÖÅäµÄÂûÑÓ£¬ËùʹÓõÄÎïÀíÄÚ´æÏòÏÂÑÓÉì¡£
When a process exits or a large enough memory block is freed, its DRAM space is unmapped and becomes a gap in memory. This process is called memory fragmentation and becomes more and more prevalent the longer a device is used and the more frequently
Ïà¹ØÎĵµ£º
ÔçÆÚµÄpingɨÃ蹤¾ßÐèÒªµÈ´ýǰһ¸ö±»Ì½²âÖ÷»ú·µ»ØÄ³ÖÖÏìÓ¦ÏûÏ¢Ö®ºó²ÅÄܼÌÐøÌ½²âÏÂһ̨Ö÷»úÊÇ·ñ´æÔÚ¡£
fpingÈ´ÄÜÒÔÂÖת·½Ê½²¢Ðеط¢³ö´óÁ¿µÄpingÇëÇó£»
sudo apt-get install fping
-a: ±íʾֻÔÚÊä³ö±¨¸æÀïÁгöµ±Ç°ÕýÔÚÔËÐеÄϵͳ¡£
-d:½âÎöÖ÷»úÃû¡£
-f£º¶ÁÈëÎļþ¡£
-g: ·¶Î§¡£
Àý×ÓÈçÏ£º
$cat a
192.168.1. ......
ÏÖÔÚʹÓÃlinuxµÄÅóÓÑÔ½À´Ô½¶àÁË£¬ÔÚlinuxÏÂ×ö¿ª·¢Ê×ÏȾÍÊÇÐèÒªÅäÖû·¾³±äÁ¿£¬ÏÂÃæÒÔÅäÖÃjava»·¾³±äÁ¿ÎªÀý½éÉÜÈýÖÖÅäÖû·¾³±äÁ¿µÄ·½·¨¡£
1.ÐÞ¸Ä/etc/profileÎļþ
Èç¹ûÄãµÄ¼ÆËã»ú½ö½ö×÷Ϊ¿ª·¢Ê¹ÓÃÊ±ÍÆ¼öʹÓÃÕâÖÖ·½·¨£¬ÒòΪËùÓÐÓû§µÄshell¶¼ÓÐȨʹÓÃÕâЩ»·¾³±äÁ¿£¬¿ÉÄÜ»á¸øÏµÍ³´øÀ´°²È«ÐÔÎÊÌâ¡£
(1)Ó ......
ÕâÆªÈÕÖ¾»¹ÊÇÏÈ´ÓÒ»¸öÄܹ»ÔËÐÐÆðÀ´µÄÀý×Ó³ö·¢£¬Ò»µ©ÄÜ˳ÀûµÄ¿´µ½³ÌÐòµÄ³É¹¦ÔËÐУ¬ÄÇô½ÓÏÂÀ´µÄʼþÎÒÏëÓ¦¸ÃÊÇÎÊΪʲôÁË£¿ËƺõÕâÑù¸ü¼ÓÈÝÒ×Àí½âºÍÕÆÎÕ¡£
¶ÔÓÚsocket³ÌÐòµÄ¸ÅÄîÕâÀï¾Í²»¶àдÁË£¬µ«ÎÒÏàÐÅ£¬Èç¹ûÄÜ¿´ÍêÕâÕûƪÎÄÕ£¬ÎÒÏàÐŲ»»áÔÙÓÐÕâÑùµÄÒÉÎʵġ£
ÏÂÃæ½«±àдһ¸öc/s½á¹¹µÄ³ÌÐò£¬Ö÷Òª¹¦ÄÜÊÇclient½«Ïòserver·¢Ë ......
±¾À´ÎÒÓõÄÊÇÕâÑùµÄ³ÌÐò
# include <iostream.h>
int main(void)
{
int i,j;
j=0;
i=j+1;
cout<<"hello world!"<<endl;
cout<<"the result is"<<i<<endl;
return 0;
}
ÀûÓÃg++ -o test test.cpp¡£µ«ÊÇÕâÑùÊÇÓдíÎóµÄ£¬ÌáʾÎÞ·¨´ ......