Ò»¸öC³ÌÐòµÄÄÚ´æ²¼¾Ö(memory layout)
Ò»¸öC³ÌÐòµÄÄÚ´æ²¼¾Ö(memory layout)
2009-09-09 15:19
Ò»¸öC³ÌÐòÒ»Ö±ÒÔÀ´¶¼ÊÇÓÉÒÔÏÂ5¸ö¶Î(pieces)×é³É£º
´úÂë¶Î(text segment)£º´æ·ÅCPUÖ´ÐеĻúÆ÷Ö¸Áî(machine instructions)¡£Í¨³£Çé¿öÏ£¬´úÂë¶ÎÊǿɹ²ÏíµÄ£¬Ê¹Æä¿É¹²ÏíµÄÄ¿µÄÊǶÔÓÚƵ·±±»Ö´ÐеijÌÐò£¬Ö»ÐèÒªÔÚÄÚ´æÖÐÓÐÒ»·Ý¿½±´¼´¿É£¬±ÈÈçÎı¾±à¼Æ÷(text editors)£¬C±àÒëÆ÷£¬shellµÈµÈ¡£ÁíÍ⣬´úÂë¶ÎҲͨ³£ÊÇÖ»¶ÁµÄ£¬Ê¹ÆäÖ»¶ÁµÄÔÒòÊÇ·ÀÖ¹Ò»¸ö³ÌÐòÒâÍâµØÐÞ¸ÄÁËËüµÄÖ¸Áî(prevent a program from accidentally modifying its instructions)¡£
³õʼ»¯Êý¾Ý¶Î/Êý¾Ý¶Î(initialized data segment/data segment):¸Ã¶Î°üº¬ÁËÔÚ³ÌÐòÖÐÃ÷È·±»³õʼ»¯µÄ±äÁ¿¡£ÀýÈ磬һ¸ö²»ÔÚÈκκ¯ÊýÄÚµÄCÉùÃ÷(C declaration)
int maxcount = 99;
ʹµÃ±äÁ¿maxcount¸ù¾ÝÆä³õʼֵ±»´æ´¢µ½³õʼ»¯Êý¾Ý¶Î¡£
δ³õʼ»¯Êý¾Ý¶Î/bss¶Î(uninitialized data segment/"bss" segment):bssÕâ¸ö½Ð·¨ÊǸù¾ÝÒ»¸öÔçÆڵĻã±àÔËËã·û¶øÀ´£¬Õâ¸ö»ã±àÔËËã·û±êÖ¾×ÅÒ»¸ö¿éµÄ¿ªÊ¼(stood for "block started by symbol")¡£ÔÚ³ÌÐò¿ªÊ¼Ö´ÐÐ֮ǰ£¬bss¶ÎµÄÊý¾Ý±»kernel³õʼ»¯Îª0»òÕß¿ÕÖ¸Õë(null pointers)¡£Ò»¸ö²»ÔÚÈκκ¯ÊýÄÚµÄCÉùÃ÷
long sum[1000];
ʹµÃ±äÁ¿sum±»´æ´¢µ½Î´³õʼ»¯Êý¾Ý¶Î/bss¶ÎÖС£
Õ»¶Î(stack)£ºwhere automatic variables are stored, along with information that is saved each time a function is called. ÿ´Îµ±Ò»¸öº¯Êý±»µ÷Ó㬸ú¯ÊýµÄ·µ»ØµØÖ·ºÍһЩ¹ØÓÚcallerµÄÐÅÏ¢£¬±ÈÈçijЩ¼Ä´æÆ÷µÄÄÚÈÝ£¬½«±»Ê×ÏÈ´æ´¢µ½Õ»¶Î¡£È»ºóÕâ¸ö±»µ÷Óõĺ¯Êý(caller)ÔÙΪËüµÄ×Ô¶¯±äÁ¿ºÍÁÙʱ±äÁ¿(automatic and temporary variables)ÔÚÕ»¶ÎÉÏ·ÖÅä¿Õ¼ä¡£Õâ¾ÍÊÇCÈçºÎʵÏÖº¯ÊýµÄµÝ¹éµ÷Óá£Ã¿´ÎÒ»¸öµÝ¹éº¯Êýµ÷ÓÃÆä±¾Éí£¬Ò»¸öеÄÕ»¿ò¼Ü(stack frame)¾Í»á±»Ê¹Óã¬ÕâÑùÕâ¸öÐÂʵÀýÕ»ÀïµÄÒ»×é±äÁ¿¾Í²»»áºÍ¸Ãº¯ÊýµÄÁíÒ»¸öʵÀýÕ»ÀïÃæµÄ±äÁ¿»¥Ïà¸ÉÈÅ¡£
¶Ñ¶Î(heap)£ºÓÃÓÚ¶¯Ì¬ÄÚ´æ·ÖÅä(dynamic memory allocation)¡£Ò»Ö±ÒÔÀ´£¬¶ÑÔÚÄÚ´æÖеÄλÖÃÊǽéÓÚbss¶ÎºÍÕ»¶ÎÖ®¼ä¡£
ͼ7.6ÏÔʾÁËÕâ5¸ö¶ÎÔÚÄÚ´æÖеĵäÐÍÅÅÁС£ÕâÊÇÒ»ÕÅÂ߼ͼ£¬±íʾÁËÒ»¸ö³ÌÐòÔÚÄÚ´æÖп´ÆðÀ´ÊÇÔõôÑùµÄ¡£¶ÔÓÚÒ»¸ö¸ø¶¨µÄʵÏÖ£¬Ã»ÓÐÇ¿ÖƵÄÒªÇó˵±ØÐë°´ÕÕÕâÖÖ·½Ê½À´ÅÅÁÐÕâ5¸ö¶Î¡£È»¶ø£¬Õâ¸øÁËÎÒÃÇÒ»ÖÖµäÐ͵ıãÓÚÃèÊöµÄÅÅÁз½Ê½¡£ÔËÐÐÔÚIntel x86´¦ÀíÆ÷ÉϵÄlinux£¬´úÂë¶Î(text segment)´ÓµØÖ·0x08048000¿ªÊ¼(ÍùÉÏ)£¬Õ»µ×´ÓµØÖ·0xC0000000ÍùÏ£¨ÔÚÕâ¸öÌض¨µÄ±íʾ½á¹¹ÖУ¬Õ»¶Î´Ó¸ßµØÖ·Ïòµ
Ïà¹ØÎĵµ£º
GNU/LinuxÓÐÁ½Ì׿â¿ÉÓÃÓÚÕýÔò±í´ïʽ±à³Ì£ºPOSIX¿âºÍPCRE¿â¡£Ç°Õß²»ÐèÒªµ¥¶À°²×°£¬Ò»°ãÐèÇó»¹ÊÇÄÜÂú×ãµÄ£¬ËÙ¶ÈÉÔÂýЩ¡£ºóÕßÊǾøºÊ¢ÃûµÄPerlÕýÔò±í´ïʽ¿â£¬¹¦ÄÜÇ¿´ó£¬Æ¥ÅäËٶȿ죬²»¹ý¿ÉÄÜÐèÒªµ¥¶À°²×°¡£
ÎÒÃÇÏÈÓÃÒ»¸öÀý×ÓÀ´½éÉÜÈçºÎʹÓÃPOSIX¿â¡£
££i nclude <stdio.h>
££i nclude <sys/ty ......
¶ÔÓÚxenµÄÐéÄ⻯¹ÜÀí£¬´ó¼Ò¶¼ÔÚÓÃʲôÄØ£¿ÎÒÕæµÄÏëÖªµÀÊDz»ÊÇ´ó¼Ò¶¼ÓÃxmÀ´½øÐйÜÀíÄØ£¿ÖÁÉÙÎÒÏë´ó¶àÊý½ö½öÏëÁ˽âһϵÄÅóÓÑ¿ÉÄÜÓÃÏÂxmÒ²¾ÍËãÊÇÁ˽âÁË¡£¶øÇÒÔÚxenµÄÓû§ÊÖ²áÀïÃæÒ²½ö½ö½éÉÜÁËÒ»ÏÂxmµÄʹÓ÷½·¨£¬¹ØÓÚÔõôʹÓÃËüµÄc½Ó¿ÚÀ´¹ÜÀíÐéÄ⻯·½ÃæµÄ½éÉÜÖ»×ÖδÌá¡£
ÎÒ²»½ö½öÏëÓÃxmÕâ¸ö¹¤¾ßÀ´´ ......
http://c.chinaitlab.com/c/basic/200907/789321.html
´Ê·¨ÏÝÚ壺
1 = ²»Í¬ÓÚ£½£½²»ÒªÔÚ³ÌÐòÖн«Á½Õßд´í£¬Ð¡ÐÄ¡£½«±í´ïʽÓë³£Á¿±È½Ïʱ£¬¿É½«³£Á¿·ÅÔÚ×ó±ß¡£
2 &ºÍ| ²»Í¬ÓÚ& ......
×î½üÒ»¶Îʱ¼äÔÚÑо¿ Pro*C Óöµ½Á˺ܶà³õ¼¶ÎÊÌâ¡£ÔÚ Pro*C ÖÐÁ¬½ÓÊý¾Ý¿âʱ£¬ÎÒÃÇÒ»°ãÊÇʹÓÃÔÚ“tnsnames.ora”ÖÐÅäÖúÃÁ¬½Ó£¬Ð´ÆðÀ´ºÜ¼òµ¥£¬Óï·¨ÈçÏ£º
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname;
/* ÕâÀïµÄ dbname ¾ÍÊÇÔÚ ......
Ôø¾Åöµ½¹ýÈÃÄãÃԻ󲻽⡢ÀàËÆÓÚint * (* (*fp1) (int) ) [10];ÕâÑùµÄ±äÁ¿ÉùÃ÷Âð£¿
±¾ÎĽ«ÓÉÒ×µ½ÄÑ£¬Ò»²½Ò»²½½Ì»áÄãÈçºÎÀí½âÕâÖÖ¸´ÔÓµÄC/C++ÉùÃ÷¡£
ÎÒÃǽ«´ÓÿÌ춼ÄÜÅöµ½µÄ½Ï¼òµ¥µÄÉùÃ÷ÈëÊÖ£¬È»ºóÖð²½¼ÓÈëconstÐÞÊηûºÍtypedef£¬»¹Óк¯ÊýÖ¸Õ룬×îºó½éÉÜÒ»¸öÄܹ»ÈÃÄã׼ȷµØÀí½âÈκÎC/C++ÉùÃ÷µÄ“ÓÒ×ó·¨Ôò&rdquo ......