¸ß¿É¿¿ÐÔC³ÌÐòµÄ¼¸µãÒªÇó
Ò»¡¢¿ÉÖØÈ뺯Êý
1£©Ê²Ã´ÊÇ¿ÉÖØÈëÐÔ£¿
¿ÉÖØÈ루reentrant£©º¯Êý¿ÉÒÔÓɶàÓÚÒ»¸öÈÎÎñ²¢·¢Ê¹Ó㬶ø²»±Øµ£ÐÄÊý¾Ý´íÎó¡£Ïà·´£¬ ²»¿ÉÖØÈ루non-reentrant£©º¯Êý²»ÄÜÓɳ¬¹ýÒ»¸öÈÎÎñËù¹²Ïí£¬³ý·ÇÄÜÈ·±£º¯ÊýµÄ»¥³â£¨»òÕßʹÓÃÐźÅÁ¿£¬»òÕßÔÚ´úÂëµÄ¹Ø¼ü²¿·Ö½ûÓÃÖжϣ©¡£¿ÉÖØÈ뺯Êý¿ÉÒÔÔÚÈÎÒâʱ¿Ì±»Öжϣ¬ÉÔºóÔÙ¼ÌÐøÔËÐУ¬²»»á¶ªÊ§Êý¾Ý¡£¿ÉÖØÈ뺯ÊýҪôʹÓñ¾µØ±äÁ¿£¬ÒªÃ´ÔÚʹÓÃÈ«¾Ö±äÁ¿Ê±±£»¤×Ô¼ºµÄÊý¾Ý¡£
2£©¿ÉÖØÈ뺯Êý£º
²»ÎªÁ¬ÐøµÄµ÷ÓóÖÓо²Ì¬Êý¾Ý¡£
²»·µ»ØÖ¸Ïò¾²Ì¬Êý¾ÝµÄÖ¸Õ룻ËùÓÐÊý¾Ý¶¼Óɺ¯ÊýµÄµ÷ÓÃÕßÌṩ¡£
ʹÓñ¾µØÊý¾Ý£¬»òÕßͨ¹ýÖÆ×÷È«¾ÖÊý¾ÝµÄ±¾µØ¿½±´À´±£»¤È«¾ÖÊý¾Ý¡£
Èç¹û±ØÐë·ÃÎÊÈ«¾Ö±äÁ¿£¬¼ÇסÀûÓû¥³âÐźÅÁ¿À´±£»¤È«¾Ö±äÁ¿¡£
¾ø²»µ÷ÓÃÈκβ»¿ÉÖØÈ뺯Êý¡£
3£©²»¿ÉÖØÈ뺯Êý£º
º¯ÊýÖÐʹÓÃÁ˾²Ì¬±äÁ¿£¬ÎÞÂÛÊÇÈ«¾Ö¾²Ì¬±äÁ¿»¹ÊǾֲ¿¾²Ì¬±äÁ¿¡£
º¯Êý·µ»Ø¾²Ì¬±äÁ¿¡£
º¯ÊýÖе÷ÓÃÁ˲»¿ÉÖØÈ뺯Êý¡£
º¯ÊýÌåÄÚʹÓÃÁ˾²Ì¬µÄÊý¾Ý½á¹¹£»
º¯ÊýÌåÄÚµ÷ÓÃÁËmalloc()»òÕßfree()º¯Êý£»
º¯ÊýÌåÄÚµ÷ÓÃÁËÆäËû±ê×¼I/Oº¯Êý¡£
º¯ÊýÊÇsingletonÖеijÉÔ±º¯Êý¶øÇÒʹÓÃÁ˲»Ê¹ÓÃÏ̶߳ÀÁ¢´æ´¢µÄ³ÉÔ±±äÁ¿ ¡£
×ܵÄÀ´Ëµ£¬Èç¹ûÒ»¸öº¯ÊýÔÚÖØÈëÌõ¼þÏÂʹÓÃÁËδÊܱ£»¤µÄ¹²ÏíµÄ×ÊÔ´£¬ÄÇôËüÊDz»¿ÉÖØÈëµÄ¡£
4£©Ê¾Àý
ÔÚ¶àÏß³ÌÌõ¼þÏ£¬º¯ÊýÓ¦µ±ÊÇḬ̈߳²È«µÄ£¬½øÒ»²½£¬¸üÇ¿µÄÌõ¼þÊÇ¿ÉÖØÈëµÄ¡£¿ÉÖØÈ뺯Êý±£Ö¤ÁËÔÚ¶àÏß³ÌÌõ¼þÏ£¬º¯ÊýµÄ״̬²»»á³öÏÖ´íÎó¡£ÒÔÏ·ֱðÊÇÒ»¸ö²»¿ÉÖØÈëºÍ¿ÉÖØÈ뺯ÊýµÄʾÀý£º
//c code
static int tmp;
void func1(int* x, int* y) {
tmp=*x;
*x=*y;
*y=tmp;
}
void func2(int* x, int* y) {
int tmp;
tmp=*x;
*x=*y;
*y=tmp;
}
func1ÊDz»¿ÉÖØÈëµÄ£¬func2ÊÇ¿ÉÖØÈëµÄ¡£ÒòΪÔÚ¶àÏß³ÌÌõ¼þÏ£¬²Ù×÷ϵͳ»áÔÚfunc1»¹Ã»ÓÐÖ´ÐÐÍêµÄÇé¿öÏ£¬Çл»µ½ÁíÒ»¸öÏß³ÌÖУ¬ÄǸöÏ߳̿ÉÄÜÔٴε÷ÓÃfunc1£¬ÕâÑù״̬¾Í´íÁË¡£
¶þ¡¢º¯Êý±àд¹æ·¶
1 £º¶ÔËùµ÷Óú¯ÊýµÄ´íÎó·µ»ØÂëÒª×Ðϸ¡¢È«ÃæµØ´¦Àí
2 £ºÃ÷È·º¯Êý¹¦ÄÜ£¬¾«È·£¨¶ø²»ÊǽüËÆ£©µØʵÏÖº¯ÊýÉè¼Æ
3 £º±àд¿ÉÖØÈ뺯Êýʱ£¬Ó¦×¢Òâ¾Ö²¿±äÁ¿µÄʹÓã¨Èç±àдC/C++ ÓïÑԵĿÉÖØÈ뺯Êýʱ£¬Ó¦Ê¹ÓÃauto ¼´È±Ê¡Ì¬¾Ö²¿±äÁ¿»ò¼Ä´æÆ÷±äÁ¿£©
˵Ã÷£º±àдC/C++ÓïÑԵĿÉÖØÈ뺯Êýʱ£¬²»Ó¦Ê¹ÓÃstatic¾Ö²¿±äÁ¿£¬·ñÔò±ØÐë¾¹ýÌØÊâ´¦Àí£¬²ÅÄÜʹº¯Êý¾ßÓпÉÖØÈë
Ïà¹ØÎĵµ£º
c º¯ÊýÖ¸Õë
º¯ÊýÖ¸ÕëÊÇʲô£¿
Ò»¸öº¯ÊýÕ¼ÓÃÒ»¶ÎÁ¬ÐøÄÚ´æ¡£µ±µ÷ÓÃÒ»¸öº¯Êýʱ£¬Êµ¼ÊÉÏÊÇÌøתµ½º¯ÊýÈë¿ÚµØÖ·£¬Ö´Ðк¯ÊýÌåµÄ´úÂ룬Íê³Éºó·µ»Ø¡£
ÈçºÎÕÒµ½¶ÔÓ¦µÄÈë¿ÚµØÖ·£¿
ÕâÊÇÓɺ¯ÊýÃûÀ´±ê¼ÇµÄ£¬Êµ¼ÊÉÏ£¬º¯ÊýÃû¾ÍÊǺ¯ÊýµÄÈë¿ÚµØÖ·¡£ º¯ÊýÖ¸ÕëÊÇÒ»ÖÖÌØÊâÀàÐ͵ÄÖ¸Õë£¬Ë ......
http://social.msdn.microsoft.com/Forums/en/sqltools/thread/07db294a-79e5-4a5a-916c-6a51e44a5aa4
http://www.pcreview.co.uk/forums/thread-211705.php
Download "MsiZap.exe" from http://support.microsoft.com/default.aspx?scid=kb;en-us;290301 ......
/*****************************************************
Îļþ:main.c
¹¦ÄÜ:²âÊÔÔËÐÐʱ¼ä(C)!
×÷Õß:chinayaosir QQ:44633197
¹¤¾ß:VC++6.0±àÒëOK!
ÈÕÆÚ:11/28/2009
´úÂëĿ¼:
//1.°üº¬Í·Îļþ
//2.mainÖ÷³ÌÐò
//²»Í¬µÄË㷨ʵÏÖµÄÐÔÄÜ,ÔËÐÐʱ¼äÏà²î·Ç³£´óµÄ!
ÐÞ¸ÄÁбí:
***************** ......