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

ǶÈëʽ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


Ïà¹ØÎĵµ£º

linux½ø³Ì¿ØÖÆ£­exit£¨£©

http://blog.chinaunix.net/u1/53053/showart_425191.html
#include<stdlib.h>
void exit(int status);
²»ÏñforkÄÇôÄÑÀí½â£¬´ÓexitµÄÃû×Ö¾ÍÄÜ¿´³ö£¬Õâ¸öϵͳµ÷ÓÃÊÇÓÃÀ´ÖÕÖ¹Ò»¸ö½ø³ÌµÄ¡£ÎÞÂÛÔÚ³ÌÐòÖеÄʲôλÖã¬Ö»ÒªÖ´Ðе½exitϵͳµ÷Ó㬽ø³Ì¾Í»áֹͣʣϵÄËùÓвÙ×÷£¬Çå³ý°üÀ¨PCBÔÚÄڵĸ÷ÖÖÊý¾Ý½á¹¹£¬²¢ÖÕÖ¹±¾½ø³ ......

ºìÆìlinux7Ï°²×°postgresql8.4.1£¨Ô´Â룩

1¡£ÏÂÔØpostgresql8.4.1Ô´Âë°ü
     ÏÂÔصØÖ·£ºhttp://www.postgresql.org/ftp/source/
2¡£½âѹԴÂë°ü
3¡£±àÒë°²×°
ÃüÁîÈçÏ£º
./configure
gmake
su
gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/ ......

Linux cµÄpopen()

½ø³ÌI/Oº¯Êý,Óëpcloseº¯ÊýÒ»ÆðʹÓá£
±íÍ·Îļþ
¡¡¡¡#include <stdio.h>
º¯Êý¶¨Òå
¡¡¡¡FILE * popen
( const char * command
, const char * type
);
¡¡¡¡int pclose
( FILE * stream
);
º¯Êý˵Ã÷
¡¡¡¡
popen() º¯Êýͨ¹ý´´½¨Ò»¸ö¹ÜµÀ£¬µ÷Óà fork ²úÉúÒ»¸ö×Ó½ø³Ì£¬Ö´ÐÐÒ»¸ö shell ÒÔÔËÐÐÃüÁîÀ´¿ªÆôÒ» ......

Linux ϱàÒëhello world µÄC ÓïÑÔ³ÌÐò

±¾À´ÎÒÓõÄÊÇÕâÑùµÄ³ÌÐò
# 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¡£µ«ÊÇÕâÑùÊÇÓдíÎóµÄ£¬ÌáʾÎÞ·¨´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ