ÕªÒª
±¾ÎÄÌÖÂÛ½«µ¥Ïß³ÌÓ¦ÓóÌÐòÖØбàд³É¶àÏß³ÌÓ¦ÓóÌÐòµÄ²ßÂÔ¡£ËüÒÔMicrosoft Windows 95ºÍWindows NTµÄƽ̨ΪÀý£¬´ÓÍÌÍÂÁ¿£¨throughput£©ºÍÏìÓ¦·½Ã棬Óë¼æÈݵĵ¥Ï̼߳ÆËãÏà±È½Ï¶ø·ÖÎöÁ˶àÏ̼߳ÆËãµÄÐÔÄÜ¡£
½éÉÜ
ÔÚÄúËùÄܹ»ÕÒµ½µÄÓйضàÏ̵߳Ä×ÊÁÏÖУ¬¶àÊý¶¼Êǽ²Êöͬ²½¸ÅÄîµÄ¡£ÀýÈ磬ÈçºÎ´®Ðл¯£¨serialize£©¹²Ïí¹«¹²Êý¾ÝµÄÏ̡߳£ÕâÖÖ°ÑÖصã·ÅÔÚÌÖÂÛͬ²½ÉÏÊÇÓÐÒâÒåµÄ£¬ÒòΪͬ²½ÊǶàÏ̱߳à³ÌÖв»¿ÉȱÉÙµÄÒ»²¿·Ö¡£±¾ÎÄÔòºóÍËÁËÒ»²½£¨takes a step back£©£¬Ö÷ÒªÌÖÂÛÓйضàÏß³ÌÖкÜÉÙÓÐÈËÉæ¼°µÄÒ»Ã棺¾ö¶¨Ò»¸ö¼ÆËãÈçºÎÄܹ»±»ÓÐÒâÒåµØ²ð·ÖΪ¶à¸öÏ̡߳£±¾ÎÄÖÐËùʹÓõÄʾÀý³ÌÐò£¬THRDPERF£¬ÔÚMicrosoft Windows 95ºÍWindows NT Á½¸öƽ̨֮ÉÏ£¬Õë¶Ôͬһ¸ö¼ÆËã²ÉÈ¡´®ÐкͲ¢·¢Á½ÖÖ·½·¨·Ö±ðʵÏÖÁ˲âÊÔÌ×¼þ£¨test suite£©£¬²¢´ÓÍÌÍÂÁ¿ºÍÐÔÄÜÁ½·½ÃæÀ´±È½ÏËüÃÇ¡£
±¾ÎĵĵÚÒ»²¿·Ö½¨Á¢ÁËһЩÓйضàÏß³ÌÓ¦ÓóÌÐòµÄ´Ê»ã£¨vocabulary£©£¬ÌÖÂÛ²âÊÔÌ×¼þµÄ·¶Î§£¬²¢ÇÒ½éÉÜÁËʾÀý³ÌÐòÌ×¼þÊÇÈçºÎÉè¼ÆµÄ¡£µÚ¶þ²¿·ÖÌÖÂÛ²âÊԵĽá¹û£¬²¢ÇÒ°üÀ¨¶ÔÓÚ¶àÏß³ÌÓ¦ÓóÌÐòÉè¼ÆµÄ½¨Òé¡£ÓëÖ®Ïà¹ØµÄÎÄÕ &q! uot;Interacting with Microsoft Excel: A Case Study in OLE Automation" ÌÖÂÛÓйظÃʾÀý³ÌÐòÌ×¼þµÄÒ»¸öÓÐȤµÄÎÊÌ⣬¼´Ê¹ÓòâÊÔ¼¯ºÏËù»ñµÃµÄÊý¾ÝÊÇÈçºÎʹÓà OLE Automation±»ÊäÈë Microsoft Excel Öеġ£
Èç¹ûÄúÊǾÑé·á¸»µÄ¶àÏß³ÌÓ¦ÓóÌÐò±à³ÌÕߣ¬Äú¿ÉÒÔÌø¹ý½éÉܲ¿·Ö£¬¶øÖ±½Óµ½ÏÂÃæµÄ"½á¹û"²¿·Ö¡£
¶àÏ̴߳ʻã
ºÜ³¤Ò»¶Îʱ¼äÒÔÀ´£¬ÄúµÄÓ¦ÓóÌÐòÒ»Ö±±»Ê¹ÓÃ--ËüÔËת³öÉ«£¬ÊÇ¿ÉÒÔÐÅÀµµÄ£¬¶øÇÒ the whole bit--µ«ËüÊ®·ÖµÄ³Ù»º£¬²¢ÇÒÄúÓÐÈçºÎÀûÓöàÏ̵߳ÄÏë·¨¡£µ«ÊÇ£¬ÔÚ¿ªÊ¼ÕâÑù×ö֮ǰÇëÉÔµÈÒ»»á¶ù£¬ÒòΪÕâÀïÓÐÐí¶àµÄÏÝÚ壬ËüÃÇʹÄúÏàÐÅijÖÖ¶àÏß³ÌÉè¼ÆÊǷdz£ÍêÃÀµÄ£¬µ«Êµ¼ÊÉϲ¢²»ÊÇÕâÑù¡£
ÔÚÄúÌøÖÁÓйØÒª½øÈëµÄ½áÂÛ֮ǰ£¬Ê×ÏÈÈÃÎÒÃdzÎÇåÒ»ÏÂÔÚ±¾ÎÄÖн«²»ÌÖÂÛµÄÄÚÈÝ£º
ÔÚ Microsoft Win32 Ó¦ÓóÌÐò±à³Ì½Ó¿Ú(API)ÏÂÌṩ¶àÏ̷߳ÃÎʵĿâÊDz»Í¬µÄ£¬µ«ÊÇÎÒÃDz»¹Ø×¢ÕâÒ»ÎÊÌ⡣ʾÀý³ÌÐòÌ×¼þ£¬Threadlib.exe£¬ÊÇÔÚÒ»¸öMicrosoft Foundation Class Library (MFC)Ó¦ÓóÌÐòÖÐʹÓÃWin32¶àÏß³ÌAPIÀ´±àдµÄ£¬µ«ÊÇ£¬ÄúÊÇʹÓÃMicrosoft CÔËÐÐʱ(CRT)¿â¡¢MFC¿â£¬»¹Êǵ¥´¿µÄ£¨barebones£© Win32 APIÀ´´´½¨ºÍά³ÖỊ̈߳¬ÎÒÃDz¢²»¹ØÐÄ¡£<! br> ʵ¼ÊÉÏ£¬Ã¿Ò»ÖÖ¿â×îºó¶¼Òªµ÷Óà Win32 ϵͳ·þÎñCreateThread! À´´´½¨Ò» ¸ö¹¤×÷Ị̈߳¬²¢ÇÒ¶àÏ̱߳¾Éí×ÜÊÇҪͨ¹ý²Ù×÷ϵͳÀ´Ö´ÐС£ÄúÏëҪʹÓÃÄÄÒ»ÖÖ°ü×°»úÖƽ«²»»áÓ°Ïì±¾ÎĵÄÂÛÌâ¡£µ±È»£¬ÄúÊÇʹÓÃijһ¸ö»¹ÊÇʹÓÃÆäËüµÄ°ü×°¿â£¨wrapper library£©£¬¿ÉÄÜ»áÒýÆðÐÔÄÜÉϵIJîÒ죬µ«ÊÇÔÚÕâ¶ù£¬ÎÒÃÇÖ÷ÒªÌÖÂÛ¶àÏ̵߳ı¾ÖÊ£¬¶ø²»¹ØÐÄÆä°ü×°(wrapper)¡£
±¾ÎÄËùÌÖÂÛµÄÊÇÔÚµ¥´¦ÀíÆ÷»úÆ÷ÉÏÔËÐеĶàÏß³ÌÓ¦ÓóÌÐò¡£¶à´¦ÀíÆ÷¼ÆËã»úÔòÊÇÒ»¸öÍêÈ«²»Í¬µÄÖ÷Ì⣬²¢ÇÒ±¾ÎÄÖÐËùÌÖÂ۵ĽáÂÛ£¬¼¸ºõûÓÐÒ»¸ö¿ÉÒÔÓ¦ÓÃÓڶദÀíÆ÷µÄ»úÆ÷ÖС£ÎÒ»¹Ã»ÓÐÕâÑùµÄ»ú»áÔÚÒ»¸öÔËÐÐ Windows NT ϵͳµÄ¿Éµ÷ÕûµÄ£¨scalable£©¶Ô³Æ¶àÏß³Ì(SMP)»úÆ÷ÉÏÖ´ÐиÃʾÀý¡£Èç¹ûÄúÓÐÕâÑùµÄ»ú»á£¬Îҷdz£¸ßÐ˵ØÏ£ÍûÖªµÀÄúµÄ½á¹û¡£
ÔÚ±¾ÎÄÖУ¬ÎÒ¸üϲ»¶Ò»°ãÐÔµØÒýÓÃ"¼ÆËã"¡£¼ÆËã±»¶¨ÒåΪÄúµÄÓ¦ÓóÌÐòµÄÒ»¸ö×ÓÈÎÎñ£¬¿ÉÒÔ±»×÷ΪÕûÌå»ò²¿·ÖÀ´Ö´ÐУ¬¿ÉÒÔÔçÓÚ»ò³ÙÓÚÁíÒ»¸ö¼ÆË㣬»òÕßÓëÆäËûµÄ¼ÆËãͬʱ·¢Éú¡£ÀýÈ磬ÈÃÎÒÃǼÙÉèij¸öÓ¦ÓóÌÐòÐèÒªÓû§µÄÊý¾Ý£¬²¢ÇÒÐèÒª±£´æÕâЩÊý¾Ýµ½´ÅÅÌ¡£ÎÒÃÇ¿ÉÒÔ¼Ù¶¨ÊäÈëÊý¾Ý°üº¬Ò»ÖÖ¼ÆË㣬¶ø±£´æÕâЩÊý¾ÝÔòÊÇÁíÒ»ÖÖ¼ÆËã¡£¸ù¾ÝÓ¦ÓóÌÐòµÄ¼ÆËãµÄÉè¼Æ£¬ÏÂÃæÁ½ÖÖÇé¿ö¶¼ÊÇ¿ÉÄܵģºÒ»ÖÖÊÇÊý¾ÝµÄ±£´æºÍÐÂÊý¾ÝµÄÊäÈëÊÇͬʱ½»²æ½øÐеģ»ÁíÒ»ÖÖÊÇÖ±µ½ÓÃ? §ÒѾÊäÈëÁËÈ«²¿µÄÊý¾Ý²Å¿ÉÊǽ«Êý¾Ý±£´æµ½´ÅÅÌÉÏ¡£µÚÒ»ÖÖÇé¿öÒ»°ã¿ÉÒÔʹÓÃijÖÖÐÎʽµÄ¶àÏß³ÌÀ´ÊµÏÖ£»ÎÒÃdzÆÕâÖÖ×éÖ¯¼ÆËãµÄ·½Ê½Îª²¢·¢»ò½»»¥¡£ºóÒ»ÖÖÇé¿öÒ»°ã¿ÉÒÔÓõ¥Ïß³ÌÓ¦ÓóÌÐòÀ´ÊµÏÖ£¬ÔÚ±¾ÎÄÖУ¬Ëü±»³ÆΪ´®ÐÐÖ´ÐС?
Óйز¢·¢Ó¦ÓóÌÐòµÄÉè¼ÆÊÇÒ»¸ö·Ç³£¸´ÔӵĹý³Ì¡£Ò»°ã·Ç³£ÓÐÇ®µÄ£¨who make a ton of money£©È˱ȽÏϲ»¶Ëü£¬ÒòΪҪ¼ÆËã³öÒ»¸ö¸ø¶¨µÄÈÎÎñ²ÉÓò¢·¢Ö´Ðе½µ×Óжà´óµÄºÃ´¦£¬Í¨³£ÐèÒª¶àÄêµÄÑо¿¡£±¾ÎIJ¢²»ÏëÒª½ÌÄúÈçºÎÉè¼Æ¶àÏß³ÌÓ¦ÓóÌÐò¡£Ïà·´£¬ÎÒÒªÏòÄúÖ¸³öijЩ¶àÏß³ÌÓ¦ÓóÌÐòÉè¼ÆµÄÎÊÌâËùÔÚ£¬¶øÇÒ£¬ÎÒʹÓÃÕæʵ£¨real-life£©µÄÐÔÄܲâÊÔÀ´ÌÖÂÛÎÒµÄÀý×Ó¡£ÔÚÔĶÁ¹ý±¾Îĺó£¬ÄúÓ¦¸ÃÄܹ»¹Û²ìÒ»¸ö¸ø¶¨µÄÉè¼Æ£¬²¢ÇÒÄܹ»¾ö¶¨Ä³ÖÖÉè¼ÆÊÇ·ñÌá¸ßÁ˸ÃÓ¦ÓóÌÐòµÄÕûÌåÐÔÄÜ¡£
¶àÏß³ÌÓ¦ÓóÌÐòÉè¼Æ²½ÖèÖеÄÒ»²¿·Ö¹¤×÷£¬¾ÍÊÇÒª¾ö¶¨Ôںδ¦´æÔÚ¿ÉÄÜDZÔÚµØÒýÆðÊý¾Ý»Ù»µµÄ¶àÏß³ÌÊý¾Ý·ÃÎʳåÍ»£¬ÒÔ¼°ÈçºÎʹÓÃÏ̵߳Äͬ²½À´±ÜÃâÕâÖÖ³åÍ»¡£ÕâÏîÈÎÎñ£¨ÒԺ󣬱¾ÎĽ«³Æ֮ΪÏ̱߳àÐò£¨thread serialization£©£©ÊÇÐí¶àÓйضàÏ̵߳ÄÎÄÕµÄÖ÷Ì⣬£¨ÀýÈ磬MSDN LibraryÖÐµÄ "Synchronization on the Fly"»ò"Compound Win32 Synchronization Objects! "£©£¬ÔÚ±¾ÎÄÖн«Ë¿ºÁ²»Éæ¼°¶ÔËüµÄÌÖÂÛ¡£ÓйØÔÚ±¾ÎÄÖÐÒªÌÖÂÛµÄ! £¬ÎÒÃǽ« ¼Ù¶¨ÐèÒª²¢·¢µÄ¼ÆËã²¢²»¹²ÏíÈκÎÊý¾Ý£¬²¢ÇÒÒò´Ë¶ø²»ÐèÒªÈκÎÏ̱߳àÐò¡£ÕâÖÖÔ¼¶¨¿´ÆðÀ´¿ÉÄÜÓеã¿Á¿Ì£¬µ«ÊÇÇëÄúÀμǣ¬²»¿ÉÄÜÓйØÓÚͬ²½¶àÏß³ÌÓ¦ÓóÌÐòµÄ"ͨÓÃ"µÄÌÖÂÛ£¬ÒòΪÿһ´Î±àÐò¶¼½«Ç¿¼ÓÒ»¸öΨһµÄ"µÈ´ý-ÐÑÀ´"½á¹¹£¨waiting-and-waking pattern£©µ½ÒѱàÐòµÄỊ̈߳¬Ëü½«Ö±½ÓµØÓ°ÏìÐÔÄÜ¡£
Win32ϵĴó¶àÊýÊäÈë/Êä³ö(I/O)²Ù×÷ÓÐÁ½ÖÖÐÎ̬£ºÍ¬²½»òÒì²½¡£ÒѾ±»Ö¤Ã÷ÔÚÐí¶àµÄÇé¿öÏ£¬Ò»¸öʹÓÃͬ²½I/OµÄ¶àÏß³ÌÉè¼Æ¿ÉÒÔ±»Ê¹ÓÃÒì²½µ¥Ïß³ÌI/OµÄÉè¼ÆÀ´Ä£Äâ¡£±¾ÎIJ¢²»ÌÖÂÛ×÷Ϊ¶àÏß³ÌÌæ´úÐÎʽµÄÒì²½µ¥Ïß³ÌI/O£¬µ«ÊÇ£¬ÎÒ½¨ÒéÄú×îºÃÁ½ÖÖÉè¼Æ¶¼¿¼ÂÇ¡£
×¢Òâµ½Win32 I/OϵͳÉè¼ÆµÄ·½Ê½ÊÇÌṩһЩ»úÖÆ£¬Ê¹µÃÒì²½I/OÒªÓÅÓÚͬ²½I/O£¨ÀýÈ磬I/OÈ«Äܶ˿ڣ¨completion ports£©£©¡£ÎҼƻ®ÔÚÒÔºóµÄÎÄÕÂÖÐÌÖÂÛÓйØͬ²½I/OºÍÒì²½I/OµÄÎÊÌâ¡£
ÕýÈçÔÚ"Multiple Threads in the User Interface"Ò»ÎÄÖÐËùÖ¸³öµÄ£¬¶àÏ̺߳ÍͼÐÎÓû§½çÃæ(GUI)²»Äܺܺõع²Í¬¹¤×÷¡£ÔÚ±¾ÎÄÖУ¬ÎÒ¼ÙÉèºǫ́Ï߳̿ÉÒÔÖ´ÐÐÆ乤×÷¶ø¸ù±¾²»ÐèҪʹÓÃWindows GUI£»ÎÒËù´¦ÀíµÄÕâÖÖÀàÐ͵ÄÏ߳̽ö½öÊÇ"¹¤×÷Ïß³Ì"£¬Ëü½öÔÚºǫִ́ÐмÆË㣬¶ø²»ÐèÒªÓëÓû§µÄÖ±½Ó? »»¥¡?
ÓÐÓÐÏÞ¼ÆË㣬ͬÑùÒ²ÓÐÓëÖ®Ïà¶ÔÓ¦µÄÎÞÏÞ¼ÆËã¡£·þÎñÆ÷¶ËÓ¦ÓóÌÐòÖеÄÒ»¸ö"ÇãÌý"Ï߳̾ÍÊÇÎÞÏÞ¼ÆËãµÄÒ»¸öÀý×Ó£¬ËüûÓÐÈκεÄÄ¿µÄ£¬Ö»ÊǵȴýÒ»¸ö¿Í»§Á¬½Óµ½·þÎñÆ÷¡£ÔÚÒ»¸ö¿Í»§ÒѾÁ¬½ÓÖ®ºó£¬¸ÃÏ߳̾ͷ¢ËÍÒ»¸ö֪ͨµ½Ö÷Ị̈߳¬²¢ÇÒ·µ»Øµ½"ÇãÌý"״̬£¬Ö±µ½ÏÂÒ»¸ö¿Í»§µÄÁ¬½Ó¡£ºÜ×ÔÈ»£¬ÕâÑùµÄÒ»ÖÖ¼ÆËã²»¿ÉÄÜפÁôÔÚͬһ¸ö×÷ΪӦÓóÌÐòÓû§½çÃæ(UI)µÄÏß³ÌÖ®ÖУ¬³ý·ÇʹÓÃÒ»ÖÖÒì²½I/O²Ù×÷¡££¨Çë×¢Ò⣬Õâ¸öÌض¨µÄÎÊÌâÄܹ»£¬Ò²Ó¦¸Ãͨ¹ýʹÓÃÒì²½I/OºÍÈ«ÄÜ£¨completion£©¶Ë¿ÚÀ´½â¾ö£¬¶ø²»ÊÇʹÓöàỊ̈߳¬ÎÒÔÚÕâÀïʹÓÃÕâ¸öÀý×Ó½ö½öÊÇÓÃ×÷ÑÝʾ£©¡£ÔÚ±¾ÎÄÖУ¬ÎÒ½«Ö»¿¼ÂÇÓÐÏÞ¼ÆË㣬¾ÍÊÇ˵£¬Ó¦ÓóÌÐòµÄ×ÓÈÎÎñ½«ÔÚÓÐÏÞµÄʱ¼ä¶ÎÖ®ºó½áÊø¡£ »ùÓÚCPUµÄ¼ÆËãºÍ»ùÓÚI/OµÄ¼ÆËã
¶ÔÓÚÒ»¸öµ¥¸öµÄỊ̈߳¬¾ö¶¨Ëù¸ø¶¨µÄ¼ÆËãÊÇ·ñÊÇÒ»¸öÓÅÐãµÄ·½°¸µÄ×îÖØÒªÒòËØÊÇ£¬¸Ã¼ÆËãÊÇÒ»¸ö»ùÓÚCPUµÄ¼ÆË㻹ÊÇ»ùÓÚI/OµÄ¼ÆËã¡£»ùÓÚCPUµÄ¼ÆËãÊÇÖ¸ÕâÖÖ¼ÆËãµÄ´ó¶àÊýʱ¼äCPU¶¼·Ç³£"æ"¡£µäÐ͵ĻùÓÚCPUµÄ¼ÆËãÈçÏ£º
¸´ÔÓµÄÊýѧ¼ÆË㣬ÀýÈ縴ÊýµÄ¼ÆË㡢ͼÐεĴ¦Àí¡¢»òÆÁÄ»ºǫ́ͼÐμÆËã ¶ÔפÁôÔÚÄÚ´æÖеÄÎļþͼÏñµÄ²Ù×÷£¬ÀýÈçÔÚÒ»¸öÎı¾ÎļþµÄÄÚ´æ¾µÏñÖеÄ? ø¶¨×Ö·û´®¡? Ïà±È½Ï¶øÑÔ£¬»ùÓÚI/OµÄ¼ÆËãÊÇÕâÑùµÄÒ»ÖÖ¼ÆË㣬Ëü? Ä´ó¶àÊýÊ ±¼äÒª»¨·ÑÔڵȴýI/OÇëÇóµÄ½áÊø¡£ÔÚ´ó¶àÊýµÄ²Ù×÷ϵͳÖУ¬ÕýÔÚ½øÈëµÄÉ豸I/O½«±»Òì²½µØ´¦Àí£¬¿ÉÄÜÊÇÓÉÒ»¸öרÃŵÄI/O´¦ÀíÆ÷À´´¦Àí£¬»òÓÉÒ»¸öÓÐЧÂʵÄÖжϴ¦Àí³ÌÐòÀ´´¦Àí£¬²¢ÇÒ£¬À´×ÔÓÚij¸öÓ¦ÓóÌÐòµÄI/OÇëÇ󽫻á¹ÒÆðµ÷ÓÃỊ̈߳¬Ö±µ½I/O½áÊø¡£Ò»°ãÀ´Ëµ£¬»¨·Ñ´ó²¿·Öʱ¼äÀ´µÈ´ýI/OÇëÇóµÄÏ̲߳»»áÓëÆäËûµÄÏß³ÌÕù¶áCPUʱ¼ä£»Òò´Ë£¬Í¬»ùÓÚCPUµÄÏß³ÌÏà±È£¬»ùÓÚI/OµÄ¼ÆËã¿ÉÄܲ»»á½µµÍÆäËûÏ̵߳ÄÐÔÄÜ£¬£¨ÉÔºó£¬ÎÒ½«½âÊÍÕâÒ»Â۵㣩
µ«ÊÇÇë×¢Ò⣬ÕâÖֱȽÏÊǷdz£ÀíÂÛÐԵġ£´ó¶àÊýµÄ¼ÆË㶼²»ÊÇ´¿´âµÄ»ùÓÚI/OµÄ»ò´¿´âµÄ»ùÓÚCPUµÄ£¬¶øÊÇ»ùÓÚI/OµÄ¼ÆËãºÍ»ùÓÚCPUµÄ¼ÆË㶼°üº¬¡£Í¬Ò»¼¯ºÏµÄ¼ÆËã¿ÉÄÜÔÚÒ»ÖÖ·½°¸ÖÐʹÓÃ˳Ðò¼ÆËã¶øÔËÐÐÁ¼ºÃ£¬¶øÔÚÁíÒ»ÖÖ·½°¸ÖÐʹÓò¢·¢µÄ¼ÆË㣬ÕâÈ¡¾öÓÚ»ùÓÚCPUµÄ¼ÆËãºÍ»ùÓÚI/OµÄ¼ÆËãµÄÏà¶Ô»®·Ö¡£
¶àÏß³ÌÉè¼ÆµÄÄ¿±ê
ÔÚÏëÒª¶ÔÄúµÄÓ¦ÓóÌÐòÓ¦ÓöàÏß³Ì֮ǰ£¬ÄúÓ¦¸ÃÎÊÎÊ×Ô¼ºÕâÖÖת±äµÄÄ¿±êÊÇʲô¡£¶àÏß³ÌÓÐÐí¶àDZÔÚµÄÓŵ㣺
ÔöÇ¿µÄÐÔÄÜ
ÔöÇ¿µÄÈÝÁ¿(throughput)
¸üºÃµØÓû§¿ìËÙÏìÓ¦(responsiveness) ÈÃÎÒÃÇÒÀ´ÎÌÖÂÛÉÏÃæµÄÿһ¸öÓŵ㡣
ÐÔÄÜ
¿¼Âǵ½Ê±¼ä£¬ÈÃÎÒÃǼòµ¥µØ¶¨Òå"ÐÔÄÜ"¾ÍÊǸø¶¨µÄÒ»¸ö! »òÒ»×é¼ÆËãËùÏûºÄµÄÈ«²¿Ê±¼ä¡£°´ÕÕÆ䶨Ò壬ÔòÐÔÄܵıȽϾͽö½öÊǶÔÓÐÏÞ¼ÆËã¶øÑԵġ£
ÎÞÂÛÄúÏàÐÅÓë·ñ£¬¶àÏ̷߳½°¸¶ÔÓ¦ÓóÌÐòµÄÐÔÄܵÄÌá¸ßÊǷdz£ÓÐÏ޵ġ£ÕâÀïÃæµÄÔÒò²»ÊǺÜÃ÷ÏÔ£¬µ«ÊÇËü·Ç³£ÓеÀÀí£º
³ý·ÇÊǸÃÓ¦ÓóÌÐòÔËÐÐÓÚÒ»¸ö¶à´¦ÀíÆ÷µÄ»úÆ÷ÉÏ£¬£¨ÔÚÕâÖÖÇé¿öÏ£¬×Ó¼ÆËãÕæÕýµØÊDz¢ÐÐÖ´Ðеģ©£¬»ùÓÚCPUµÄ¼ÆËãÔÚ¶àÏß³ÌÇé¿öϲ»¿ÉÄܱÈÔÚµ¥Ïß³ÌÇé¿öϵÄÖ´ÐÐËٶȿ졣ÕâÊÇÒòΪ£¬ÎÞÂÛ¼ÆËã±»·Ö½â³ÉС¿é£¨ÔÚ¶àÏ̵߳ÄÇé¿öÏ£©»ò´ó¿é£¨ÔÚͬһÏß³ÌÖмÆË㰴˳Ðò°¤¸öÖ´ÐеÄÇé¿öÏ£©£¬Ö»ÓÐÒ»¸öCPU£¬¶øÇÒËü±ØÐèÖ´ÐÐËùÓеļÆËã¡£½á¹ûÊÇ£¬¶ÔÓÚÒ»×é¸ø¶¨µÄ¼ÆË㣬Èç¹ûÊÇÒÔ¶à¸öÏß³ÌÀ´Ö´ÐУ¬ÄÇôһ°ã»á±È°´´®Ðз½Ê½¼ÆËãÍê³ÉµÄʱ¼äÒª³¤£¬ÒòΪËüÔö¼ÓÁË´´½¨Ï̺߳ÍÔÚÏß³ÌÖ®¼äÇл»CPUµÄ¶îÍ⸺µ£¡£ Ò»°ãÀ´Ëµ£¬±Ø¶¨»áÓÐijЩÇé¿ö£¬ÎÞÂÛ¶à¸ö¼ÆËãµÄÍê³ÉËÏÈ˺󣬵«ÊÇËüÃǵĽá¹û±ØÐèͬ²½¡£ÀýÈ磬ʹÓöà¸öÏß³ÌÀ´²¢·¢µÄ¶Á¶à¸öÎļþµ½ÄÚ´æÖУ¬ÄÇôÎļþ±»´¦ÀíµÄ˳ÐòÎÒÃÇÊDz»¹ØÐĵģ¬µ«ÊDZØÐèµÈµ½ËùÓеÄÊý¾Ý¶¼¶ÁÈëÄÚ´æÖ®ºó£¬Ó¦ÓóÌÐò²ÅÄÜ¿ªÊ¼´¦Àí¡£ÎÒÃǽ«ÔÚ"ÈÝÁ¿"Ò»½ÚÌÖÂÛÕâ¸öÏë·¨¡£ ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÒÔÏûºÄµÄʱ¼ä£¬¼´Íê³ÉËùÓеļÆËãËùÏûºÄµÄ×ܵÄʱ¼ä£¬À´ºâÁ¿ÐÔÄÜ¡£ <! br>ÈÝÁ¿(Throughput)
ÈÝÁ¿£¨»òÏìÓ¦£©£¬ÊÇָÿһ¸ö¼ÆËãµÄƽ? ù´¦ÀíÖÜÆ ?turnaround)µÄʱ¼ä¡£ÎªÁËÑÝʾÈÝÁ¿£¬ÈÃÎÒÃǼÙÉèÒ»¸ö³¬¼¶Êг¡µÄÀý×Ó£¨Ëü×ÜÊÇÒ»¸öÓйزÙ×÷ϵͳµÄ¼«ºÃµÄÑÝʾ¹¤¾ß£©£º¼ÙÉèÿһ¸ö¼ÆËã¾ÍÊÇÒ»¸öÔÚ½áËã¹ñ̨±»·þÎñµÄ¹Ë¿Í¡£¶ÔÓÚ³¬¼¶Êг¡À´Ëµ£¬¼È¿ÉÒÔΪÿһ¸ö¹Ë¿Í¿ªÉèÒ»¸ö½áËã¹ñ̨£¬Ò²¿ÉÒÔ°ÑËùÓеĹ˿ͼ¯ÖÐÆðÀ´Í¨¹ýÒ»¸ö½áËã¹ñ̨¡£ÎªÁËÎÒÃÇ·ÖÎöµÄÐèÒª£¬¼ÙÉèÊÇÓжà¸ö½áËã¹ñ̨µÄÇé¿ö£¬µ«ÊÇ£¬½öÓÐÒ»¸öÊÕÒøÔ±£¨¿ÉÁ¯µÄ¼Ò»ï£¡£©À´·þÎñËùÓеĹ˿ͣ¬¶ø²»¿¼Âǹ˿ÍÊÇÔÚÒ»¸ö¹ñ̨ǰÅŶӻò¶à¸ö¹ñ̨ǰÅŶӡ£Õâ¸ö³¬¼¶ÊÕÒøÔ±½«¸ßËٵشÓÒ»¸ö¹ñ̨Ìøµ½ÏÂÒ»¸ö¹ñ̨£¬Ò»´Î½ö´¦Àí(ringing up)Ò»¸ö¹Ë¿ÍµÄÒ»¼þÉÌÆ·£¬È»ºó£¬¾ÍÒƶ¯µ½ÏÂÒ»¸ö¹Ë¿Í¡£Õâ¸ö³¬¼¶µÄÊÕÒøÔ±¾ÍÏóÊDZ»¶à¸ö¼ÆËãËù¸îÁѵÄCPU¡£
¾ÍÏóÎÒÃÇÔÚÇ°ÃæµÄ"ÐÔÄÜ"Ò»½ÚÖÐËù¿´µ½µÄ£¬·þÎñËùÓй˿͵Ä×ܵÄʱ¼ä²¢Ã»ÓÐÒòΪÓжà¸ö½áËã¹ñ̨´ò¿ª¶ø¼õÉÙ£¬ÒòΪÎÞÂ۹˿ÍÊÇÔÚÒ»¸ö¹ñ̨»¹ÊǶà¸ö¹ñ̨±»·þÎñ£¬×ÜÊÇÕâÒ»¸öÊÕÒøÔ±À´Íê³ÉËùÓеŤ×÷¡£µ«ÊÇ£¬ÊÂÇéÊÇÕâÑù£¬Í¬Ö»ÓÐÒ»¸ö½áËã¹ñ̨Ïà±È£¬¹Ë¿Í»¹ÊÇϲ»¶ÕâÖÖ³¬¼¶ÊÕÒøÔ±µÄ·½Ê½¡£ÕâÊÇÒòΪһ°ãÇé¿öÏ£¬¹Ë¿ÍµÄÊÖÍƳµÀïµÄÉÌÆ·ÊýµÄ²î±ðÊǾ޴óµÄ£¬Ä³Ð©¹Ë¿ÍµÄÊÖÍƳµÖÐÓÐÒ»´ó¶ÑµÄÉÌÆ·£¬¶øijЩ¹Ë¿ÍÔòÖ»ÏëÂòºÜÉÙ¼¸¼þÉÌÆ·¡£Èç¹ûÄúÔø¾Ö»Ï£ÍûÂòÒ»ºÐ granola bars! ºÍÒ»¿äÍÑÅ£ÄÌ£¬¶øÈ´ÅÅÔÚij¸öÀ´ÎªÈ«¼Ò24¿ÚÈ˲ɹºµÄÏÈÉúºóÃ棬ÄÇÄú¾ÍÖªµÀÎÒ˵µÄÊÇÒâζ×ÅʲôÁË¡£
ÎÞÂÛÔõÑù£¬Èç¹ûÄúÄܹ»±» Clark Kent ÏÈÉúÒÔ¸ßËٶȷþÎñ£¬¶ø²»ÊÇÔÚÄÇÀïÅŶӣ¬Äú¾Í²»»áÌ«ÔÚÒâÍê³É½áÕʵÄʱ¼äÊÇ·ñÉÔ³¤£¬ÒòΪ²»¹ÜÔõôÑù£¬Á½¼þÉÌÆ·¶¼»áºÜ¿ìµØ±»´¦ÀíÍê¡£¶øÂúÔØ×ÅΪ24¿ÚÈ˲ɹºµÄÉÌÆ·µÄÊÖÍƳµÊÇÔÚÁíÒ»¸ö¹ñ̨±»´¦ÀíµÄ£¬ËùÒÔÄú¿ÉÒԺܿì¾ÍÍê³É½áÕʶøÀ뿪¡£
Òò´Ë£¬ÈÝÁ¿¾ÍÊǶÈÁ¿ÔÚÒ»¸ö¸ø¶¨µÄʱ¼äÄÚÓжàÉÙ¸ö¼ÆËã¿ÉÒÔ±»Ö´ÐС£Ã¿Ò»¸ö¼ÆËãÊÇÕâÑù¶ÈÁ¿ËüµÄ½ø³ÌµÄ£¬ÄǾÍÊÇÒª±È½ÏÒÔϵÄÁ½¸öʱ¼ä£ºÍê³É±¾¼ÆË㻨·ÑÁ˶àÉÙµÄʱ¼ä£¬ÒÔ¼°¼ÙÉè¸Ã¼ÆËã±»Ê×ÏÈ´¦ÀíµÄ»°Òª»¨·Ñ¶àÉÙʱ¼ä¡£»»¾ä»°Ëµ£¬Èç¹ûÄúÈ¥Á˳¬¼¶Êг¡£¬²¢ÇÒÏ£ÍûÁ½·ÖÖÓ¾ÍÀ뿪ÄÇÀµ«ÊÇʵ¼ÊÉÏÄú»¨·ÑÁËÁ½¸öСʱÀ´ÎªÄúµÄÁ½¼þÉÌÆ·½áË㣬ÔÒòÊÇÄúÅÅÔÚÁ˹ºÂòÆä1997Éú²úÏßµÄ Betty Crocker µÄºóÃ棬ÄÇô²»µÃ²»Ëµ£¬ÄúµÄ½ø³Ì·Ç³£Ê§°Ü¡£
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÕâÑù¶¨ÒåÒ»¸ö¼ÆËãµÄÏìӦʱ¼ä£¬¼ÆËãÍê³ÉËùÏûºÄµÄʱ¼ä³ýÒÔÔ¤¼ÆÒªÏûºÄµÄʱ¼ä¡£ÄÇô£¬Èç¹ûÒ»¸öÓ¦¸ÃÏûºÄ 10 ºÁÃë(ms)µÄ¼ÆË㣬¶øʵ¼ÊÉÏÏûºÄÁË 20 ms£¬ÄÇôËüµÄÏìÓ¦´¦ÀíÖÜÆÚ¾ÍÊÇ 2£¬µ«ÊÇ£¬Èç¹û¾ÍÊÇͬһ¸ö¼ÆË㣬ȴÏûºÄÁË 200 ms £¨¿ÉÄÜÊÇÒòΪÓÐÁíÒ»¸ö³¤µÄ¼ÆËãÓëÖ®? ºÕù²¢ÓÅÏÈ£©²Å½áÊø£¬ÄÇôÏìÓ¦´¦ÀíÖÜÆÚ¾ÍÊ?20¡£ÏÔÈ»£¬ÏìÓ¦´¦ÀíÖÜÆÚ! ÊÇÔ½¶ÌÔ½ ºÃ¡£
ÎÒÃÇÔÚºóÃ潫»á¿´µ½£¬ÔÚ½«¶àÏß³ÌÒýÈëÒ»¸öÓ¦ÓóÌÐòÖÐʱ£¬¼´Ê¹µ¼ÖÂÁËÕûÌåÐÔÄܵÄϽµ£¬ÈÝÁ¿ÈÔÈ»¿ÉÄÜÊÇÒ»¸öÓÐʵ¼ÊÒâÒåµÄÒòËØ£»µ«ÊÇ£¬ÒªÊ¹ÈÝÁ¿³ÉΪһ¸öÓÐʵ¼ÊÒâÒåµÄÒòËØ£¬±ØÐèÂú×ãÏÂÃæµÄһЩÌõ¼þ£º
ÿһ¸ö¼ÆËã±ØÐèÊÇÏ໥¶ÀÁ¢µÄ£¬Ö»Òª¼ÆËãÒ»½áÊø£¬ÈκμÆËãµÄ½á¹û¶¼¿ÉÒÔ±»´¦Àí»òʹÓá£Èç¹ûÄúÊÇij¸ö´óѧ×ãÇò¶ÓµÄ¶ÓÔ±£¬¶øÇÒÄúÃÇÿһ¸ö¶ÓÔ±¶¼ÔÚͬһ¸ö³¬¼¶Êг¡Âò×Ô¼ºµÄÂÃÐÐʳƷ£¬ÄÇôÄúµÄÉÌÆ·ÊÇÏȱ»´¦Àí»¹ÊǺ󱻴¦Àí¡¢Äú»¨·ÑÁ˶೤µÄʱ¼äΪÁ½¼þÉÌÆ·½áÕÊ¡¢ÒÔ¼°ÄúΪ´ËµÈ´ýÁ˶೤µÄʱ¼ä£¬ÕâЩ¶¼Î޹ؽôÒª£¬ÒòΪ×îºóÄúµÄÆû³µÊDz»»áÀ뿪µÄ£¬³ý·ÇËùÓеĶÓÔ±¶¼ÂòÍêÁËʳƷ¡£Ëù²»Í¬µÄÖ»ÊÇÄúµÄµÈ´ýʱ¼ä£¬ÒªÃ´ÊÇ»¨·ÑÔÚÅŶӵȴý½áÕÊ£¬ÒªÃ´ÊÇÈç¹û³¬¼¶ÊÕÒøÔ±ÒѾΪÄú·þÎñ£¬Ê±¼ä¾Í»¨·ÑÔڵȴýÆäËûÈËÉÏ¡£
ÕâÒ»µãºÜÖØÒª£¬µ«È´³£±»ºöÂÔ¡£¾ÍÏóÎÒÇ°ÃæËùÌáµ½µÄ£¬´ó¶àÊýµÄÓ¦ÓóÌÐò³ÙÔ綼»áÏÔʽ»òÒþʽµØͬ²½Æä¼ÆËã¡£ÀýÈ磬Èç¹ûÄúµÄÓ¦ÓóÌÐò´Ó²»Í¬µÄÎļþ²¢·¢µØÊÕ¼¯Êý¾Ý£¬Äú¿ÉÄÜ»áÏëÒªÔÚÆÁÄ»ÉÏÏÔʾ½á¹û£¬»òÕß°ÑËüÃDZ£´æµ½ÁíÒ»¸öÎļþÖС£ÔÚÇ°ÃæÒ»ÖÖÇé¿öÏ£¨ÔÚÆÁÄ»ÉÏÏÔʾ½á¹û£©£¬ÄúÓ¦¸ÃÒâʶµ½£¬´ó¶àÊýͼÐÎϵͳ¶¼Ö´ÐÐijÖÖµÄÄÚ²¿Åú´¦Àí»ò´®ÐвÙ×÷£¬³ý·ÇËùÓеÄÊä³öÊý¾Ý¶¼ÒÑÊÕ¼¯µ½£¬? ñÔòÊǸù±¾²»»áÓкõÄÏÔʾµÄ£»ÔÚºóÃæµÄÇé¿öÏ£¬£¨±£´æ½á¹ûµ½ÁíÒ»¸öÎļþ£©£¬³ý·ÇÕû¸öÔÐÍÎļþÒѱ»Ð´ÈëÍê±Ï£¬Ò»°ã²»ÊÇÄúµÄÓ¦ÓóÌÐò£¨»òÆäËûµÄÓ¦ÓóÌÐò£©ËùÄÜÍêÈ«´¦ÀíµÄ¡£ËùÒÔ£¬Èç¹ûij¸öÈË»òijЩ¶«Î÷ÒÔijÖÖÐÎʽ½«½á¹û˳Ðò»¯ÁË£¬²»¹ÜÊÇÓ¦ÓóÌÐò¡¢²Ù×÷ϵͳ¡¢ÉõÖÁÊÇÓû§£¬ÄÇôÄúÔÚ´¦ÀíÎļþʱËùÄܵõ½µÄºÃ´¦¿ÉÄܾͻáÏûʧÁË¡?br>
¼ÆËãÖ®¼äÔÚÁ¿ÉϱØÐèÓÐÃ÷ÏԵIJîÒì¡£Èç¹û³¬¼¶Êг¡ÖеÄÿһ¸ö¹Ë¿Í¶¼Ö»ÓÐÁ½¼þÉÌÆ·ÐèÒª½áÕÊ£¬Ôò³¬¼¶ÊÕÒøÔ±·½Ê½Ò»µãÓÅÊƶ¼Ã»ÓУ»Èç¹ûËû²»µÃ²»ÔÚ3¸ö½áËã¹ñ̨֮¼äÌøÀ´ÌøÈ¥£¬¶øÿһ¸öÒª±»·þÎñµÄ¹Ë¿Í½öÓÐ2¸ö£¨»ò3¸ö¡¢4¸ö»òn¸ö£©ÉÌÆ·Òª½áË㣬ÄÇôÿһ¸ö¹Ë¿Í¶¼²»µÃ²»µÈ´ý¼¸±¶µÄʱ¼äÀ´Íê³ÉËû»òËýµÄ½áË㣬Õâ±ÈÈÃËùÓеĹ˿ÍÔÚÒ»ÆðÅŶӻ¹ÒªÔã¸â¡£ÔÚÕâÀï°Ñ¶àÏß³ÌÏëÏóΪshockÎüÊÕ×°Ö㺶̵ļÆËã²¢²»»áð±»ÅÅÔÚ³¤µÄ¼ÆËãÖ®ºóµÄΣÏÕ£¬µ«ÊÇËüÃDZ»·Ö³ÉÏ̲߳¢ÇÒ»¨·ÑÁ˸ü¶àµÄʱ¼ä£¬¶ø±¾À´ËüÃÇ¿ÉÒÔÔÚ¸ü¶ÌµÄʱ¼äÄÚÍê³É¡£
Èç¹û¼ÆËãµÄ³¤¶Ì¿ÉÒÔÊÂÏȾö¶¨£¬ÄÇô´®Ðд¦Àí¿ÉÄܱȶàÏ̴߳¦ÀíÒªºÃ£¬ÄúÖ»Òª¼òµ¥µØÒÔʱ¼ä³¤¶Ì°´ÉýÐòÅÅÁмÆËã¾Í¿ÉÒÔÁË¡£ÔÚ³¬¼¶Êг¡µÄÀý×ÓÖУ¬¾ÍÏ൱ÓÚ°´Õչ˿͵ÄÉÌÆ·ÊýÀ´Õ¾ÅÅ£¨Express Lane ·½°¸µÄÒ»ÖÖ±äÖÖ£©£¬ÕâÖÖÏë·¨ÊÇ»ùÓÚÕâÑùµÄ¿¼ÂÇ! £¬Ö»ÓкÜÉÙµÄÉÌÆ·µÄ¹Ë¿ÍºÜϲ»¶Ëü£¬ÒòΪËûÃDz»»áΪһµãµÄÊÂÇé¶øµ¢Îó! ºÜ¶àµÄʱ ¼ä£¬ ¶øÄÇЩÓкܶà»õÎïµÄ¹Ë¿ÍÒ²²»»áÔÚÒ⣬ÒòΪÎÞÂÛÈçºÎÒªÍê³ÉÆäËùÓеĽáË㶼Ҫ»¨·ÑºÜ³¤µÄʱ¼ä£¬¶øÇÒÔÚËûÃÇÇ°ÃæµÄÿһ¸öÈ˵ÄÉÌÆ·¶¼±ÈËüÉÙ¡£ Èç¹ûÖ»ÊÇ´óÖÂÖªµÀ¼ÆËãʱ¼äµÄÒ»¸ö·¶Î§£¬µ«ÊÇÄúµÄÓ¦ÓóÌÐò²»ÄÜÅÅÐòÕâЩ¼ÆË㣬ÄÇôÄúÓ¦¸Ã»¨Ð©Ê±¼ä×öÒ»´Î×Çé¿öµÄ·ÖÎö¡£ÔÚÕâÑùµÄ·ÖÎöÖУ¬ÄúÓ¦¸Ã¼Ù¶¨ÕâЩ¼ÆËã²»ÊÇ°´ÕÕʱ¼äµÄÉýÐò˳ÐòÀ´ÅÅÐòµÄ£¬Ïà·´£¬ËüÃÇÊÇ°´ÕÕʱ¼äµÄ½µÐòÀ´ÅÅÐòµÄ¡£´ÓÏìÓ¦Õâ¸ö½Ç¶ÈÀ´½²£¬ÕâÖз½°¸ÊÇ×µÄÇéÐΣ¬ÒòΪ°´ÕÕÇ°ÃæËù¶¨ÒåµÄ¹«Ê½£¬Ã¿Ò»¸ö¼ÆË㶼½«¾ßÓÐÆä×î¸ß¿ÉÄܵÄÏìÓ¦´¦ÀíÖÜÆÚ¡£
¿ìËÙÏìÓ¦(Responsiveness)
ÎÒ½«ÔÚÕâÀïÌÖÂ۵ġ¢Ó¦ÓóÌÐò¶àÏ̻߳¯µÄ×îºóÒ»¸ö×¼ÔòÊÇ¿ìËÙÏìÓ¦£¨ÔÚÓïÑÔÉÏÓëÏìÓ¦·Ç³£½Ó½ü£¬×ãÒÔʹÄúÃԻ󲻽⣩¡£ÔÚ±¾ÎÄÖУ¬Èç¹ûÒ»¸öÓ¦ÓóÌÐòµÄÉè¼ÆÊDZ£Ö¤Óû§×ÜÊÇÄܹ»ÔÚÒ»¸öºÜ¶ÌµÄʱ¼ä£¨ºÜ¶ÌµÄʱ¼äָʱ¼ä·Ç³£¶Ì£¬Ê¹µÃÓû§¸Ð¾õ²»µ½Ó¦ÓóÌÐò±»¹ÒÆð£©ÄÚÍê³ÉÓëÓ¦ÓóÌÐòµÄ½»»¥£¬ÄÇôÎÒÃǾͼòµ¥Ò»µã£¬¶¨Òå¸ÃÓ¦ÓóÌÐòΪÏìÓ¦¿ìËÙµÄÓ¦ÓóÌÐò¡£
¶ÔÓÚÒ»¸ö´øÓÐ GUI µÄ Win32 Ó¦ÓóÌÐò£¬¿ìËÙÏìÓ¦¿ÉÒÔ±»ºÜ¼òµ¥µØʵÏÖ£¬Ö»ÒªÈ·±£³¤µÄ¼ÆË㱻ίÍиøºǫ́Ị̈߳¬µ«ÊÇʵÏÖ¿ìËÙÏìÓ¦ËùÒªÇóµÄ½á¹¹¿ÉÄÜÒªÇó½Ï¸ßµÄ¼¼ÇÉ£¬ÕýÈçÎÒÇ°ÃæËùÌáµ½µÄ£¬Ä³Ð©ÈË¿É? Ü»áµÈ´ýij¸ö¼ÆËãÔÚij¸öʱ¼ä·µ»Ø£¬ËùÒÔÔÚºǫִ́ÐÐÒ»¸ö³¤µÄ¼ÆËã¿ÉÄÜÐèÒª¸Ä±äÓû§½çÃ棨ÀýÈ磬ÐèÒªÌí¼ÓÒ»¸?quot;È¡Ïû"°´Å¥£¬²¢ÇÒÒÀÀµ¸Ã¼ÆËã½á¹ûµÄ²Ëµ¥ÏîÒ²²»µÃ²»±ä»Ò£©¡£
³ýÁËÐÔÄÜ¡¢ÈÝÁ¿ºÍ¿ìËÙÏìÓ¦Ö®Í⣬ÆäËûµÄһЩÔÒòÒ²¿ÉÄÜÓ°Ïì¶àÏß³ÌÉè¼Æ¡£ÀýÈ磬ÔÚijЩ½á¹¹Ï£¬±ØÐèÈüÆËãÒÔÒ»ÖÖαËæ»ú·½Ê½£¨ÄÔº£ÖÐÔٴγöÏÖµÄÀý×ÓÊÇBolzmann »úÆ÷ÀàÐ͵ÄÉñ¾ÍøÂ磬ÔÚÕâÖÖÍøÂçÖУ¬½öµ±¸ÃÍøÂçÖеÄÿһ¸ö½ÚµãÒì²½Ö´ÐÐÆä¼ÆËãʱ£¬¸Ã»¥ÁªÍøÂçµÄÔ¤ÆÚÐÐΪ²ÅÄܹ»¹¤×÷£©¡£µ«ÊÇ£¬ÔÚ±¾ÎÄÖУ¬ÎÒ½«°ÑÌÖÂ۵ķ¶Î§ÏÞÖÆÔÚÉÏÃæËùÉæ¼°µÄÈý¸öÒòËØ£¬ÄǾÍÊÇ£ºÐÔÄÜ¡¢ÈÝÁ¿ºÍ¿ìËÙÏìÓ¦¡£
²âÊÔµÄʵÏÖ
ÎÒÔø¾Ìý˵¹ýÐí¶à¹ØÓÚ³éÏó(abstraction)»úÖƵÄÌÖÂÛ£¬ËµËü·â×°ÁËËùÓжàÏ̵߳ÄÔã¸â(nasty)·½Ãæµ½Ò»¸ö C++ ¶ÔÏóÖУ¬²¢ÇÒÒò´Ëʹһ¸öÓ¦ÓóÌÐò»ñµÃÁ˶àÏ̵߳ÄÈ«²¿Óŵ㣬¶ø²»ÊÇȱµã¡£
ÔÚ±¾ÎÄÖУ¬ÎÒÒ»¿ªÊ¼¾ÍÉè¼ÆÕâÑùÒ»¸ö³éÏó¡£ÎÒ½«ÎªÒ»¸ö C++ µÄÀà ConcurrentExecution ¶¨ÒåÒ»¸öÔÐÍ£¬¸ÃÀཫº¬ÓгÉÔ±º¯ÊýÀýÈ磺DoConcurrent ºÍ DoSerial£¬²¢ÇÒÕâÁ½¸ö³ÉÔ±º¯ÊýµÄ²ÎÊý½«ÊÇÒ»¸öÆÕͨ¶ÔÏóÊý×éºÍÒ»¸ö»Øµ÷º¯ÊýÊý×飬ÕâЩ»Øµ÷º¯Êý½«±»Ã¿Ò»¸ö¶ÔÏó²¢·¢»ò´®Ðеص÷Ó᣸à C++ Àཫ·â×°ËùÓйØÓÚ±£³Ö! ¸ÃÏ̺߳ÍÄÚ²¿Êý¾Ý½á¹¹µÄÕæʵ(gory)ϸ½Ú¡£
µ«ÊÇ£¬¶ÔÎÒÀ´Ëµ£¬! ´ÓÒ»¿ªÊ¼ ÎÒ¾ÍÊ®·ÖÇå³þ£¬ÕâÑùµÄÒ»¸ö³éÏóµÄÓô¦Ê®·ÖÓÐÏÞ£¬ÒòΪÔÚÉè¼ÆÒ»¸ö¶àÏß³ÌÓ¦ÓóÌÐòʱµÄ×î´óÁ¿µÄ¹¤×÷³ÉÁËÒ»¸öÎÞ·¨×Ô¶¯Íê³ÉµÄÈÎÎñ£¬Õâ¸ö¹¤×÷¾ÍÊǾö¶¨ÈçºÎʵÏÖ¶àÏ̡߳£ConcurrentExecution µÄµÚÒ»¸öÏÞÖÆÊǻص÷º¯Êý½«²»ÔÊÐíÏÔʽ»òÒþʽµÄ¹²ÏíÊý¾Ý£»»ò»Øµ÷º¯ÊýÐèÒªÈκÎÆäËûÐÎʽµÄͬ²½²Ù×÷£¬¶øÕâЩͬ²½²Ù×÷½«Á¢¿ÌÎþÉüµôËùÓиóéÏóËù´øÀ´µÄÓŵ㣬²¢ÇÒ´ò¿ªËùÓÐ"¾«²Ê"µÄͬ²½ÊÀ½çÖеÄÏÝÚåºÍȦÌ×£¬ÀýÈçËÀËø¡¢¾ºÕù³åÍ»¡¢»òÐèÒª·Ç³£¸´Ôӵĸ´ºÏͬ²½¶ÔÏó¡£
ͬÑù£¬Ò²²»ÔÊÐíÄÇЩ¿ÉÄÜDZÔڵر»²¢·¢Ö´ÐеļÆËãÀ´µ÷Óà UI£¬ÒòΪ¾ÍÏóÎÒÇ°ÃæËù½²µ½µÄ£¬Win32 API ¶ÔÓÚµ÷Óà UI µÄÏß³ÌÇ¿ÆÈÁËÐí¶à¸öÒþʽµÄͬ²½²Ù×÷¡£Çë×¢Ò⣬»¹ÓÐÐí¶àÆäËûµÄ API ×Ó¼¯ºÍ¿â¶ÔÓÚ¹²ÏíËüÃǵÄÏß³ÌÇ¿ÆÈÁËÒþʽµÄͬ²½²Ù×÷¡£
ÕâЩµÄÏÞÖÆʹ ConcurrentExecution Ö»¾ßÓм«ÆäÓÐÏ޵ŦÄÜ£¬Ëµ¾ßÌåÒ»µã£¬¾ÍÊÇÒ»¸ö¹ÜÀí´¿´â¹¤×÷ÕßÏ̵߳ijéÏó£¨ÍêÈ«¶ÀÁ¢µÄ¼ÆËã´ó¶àÊýÇé¿öϽöÏÞÓÚÔÚ·ÇÁ¬ÐøÄÚ´æÇøÓòµÄÊýѧ¼ÆË㣩¡£
È»¶ø£¬ÊÂʵ֤Ã÷ʵÏÖ ConcurrentExecution ÀಢÇÒÔÚÐÔÄܲâÊÔÖÐʹÓÃËüÊǷdz£ÓÐÓõģ¬ÒòΪ£¬µ±ÎÒʵÏÖÁ˸ÃÀ࣬²¢ÇÒÉè¼ÆºÍÔËÐÐÁ˸òâÊÔ֮ʱ£¬Ðí¶à¹ØÓÚ¶àÏ̵߳ÄÒþ²ØÆðÀ´µÄϸ½Ú¶¼±©Â¶³öÀ´ÁË¡£ÇëÇå³þÒÔ? ÂÒ»µã£¬ËäÈ?ConcurrentExecution Àà¿ÉÒÔʹ¶àÏ̸߳üÈÝÒ×´¦Àí£¬µ«ÊÇÈç¹ûÏëÒªÔÚÉÌÒµ²úÆ·ÖÐʹÓÃËü£¬ÄÇô¸ÃÀàµÄʵÏÖ»¹ÐèҪһЩÆäËûµÄ¹¤×÷¡£ÌرðÒªÌáµ½µÄÒ»µãʱ£¬ÎÒºöÂÔÁËËùÓеĴíÎóÇé¿ö´¦Àí£¬ÕâÊDz»¿ÉÈÌÊܵġ£µ«ÊÇÎÒ¼Ù¶¨Ö»ÓÃÓÚ²âÊÔʱ£¨ÎÒÃ÷ÏÔµØʹÓÃÁË ConcurrentExecution£©£¬´íÎó²»»á³öÏÖ¡£
ConcurrentExecution Àà
ÏÂÃæÊÇ ConcurrentExecution ÀàµÄÔÐÍ£º
class ConcurrentExecution { < private members omitted> public: ConcurrentExecution(int iMaxNumberOfThreads); ~ConcurrentExecution(); int DoForAllObjects(int iNoOfObjects,long *ObjectArray, CONCURRENT_EXECUTION_ROUTINE pObjectProcessor, CONCURRENT_FINISHING_ROUTINE pObjectTerminated); BOOL DoSerial(int iNoOfObjects, long *ObjectArray, CONCURRENT_EXECUTION_ROUTINE pObjectProcessor, CONCURRENT_FINISHING_ROUTINE pObjectTerminated); };
¸ÃÀàÊÇ´Ó Thrdlib.dll ¿âÖе¼³öµÄ£¬¶ø Thrdlib.dll ¿âÊÇʾÀý²âÊÔÌ×¼þ THRDPERF ÖеÄÒ»¸ö¹¤³Ì¡£ÔÚÌÖÂÛ¸ÃÀàµÄÄÚ²¿½á¹¹Ö®Ç°£¬ÈÃÎÒÃÇÊ×ÏÈÌÖÂÛ³ÉÔ±º¯ÊýµÄÓïÒ壨semantics£©£º<! br> ConcurrentExecution::ConcurrentExecution(int iMaxNumber! OfThread s) { m_iMaxArraySize = min(iMaxNumberOfThreads, MAXIMUM_WAIT_OBJECTS); m_hThreadArray = (HANDLE *)VirtualAlloc(NULL,m_iMaxArraySize*sizeof(HANDLE), MEM_COMMIT,PAGE_READWRITE); m_hObjectArray = (DWORD *)VirtualAlloc(NULL,m_iMaxArraySize*sizeof(DWORD), MEM_COMMIT,PAGE_READWRITE); // µ±È»£¬Ò»¸öÕæÕýµÄʵÏÖ±ØÐèÔÚÕâÀïÌṩ¶Ô´íÎóµÄ´¦Àí... };
Äú¿ÉÄÜ»á×¢Òâµ½¹¹Ô캯Êý ConcurrentExecution ÓÐÒ»¸öÊý×Ö²ÎÊý¡£¸Ã²ÎÊýÖ¸¶¨Á˸ÃÀàµÄʵÀýËùÖ§³ÖµÄ"²¢·¢µÄ×î´ó¶ÈÊý"£»»»¾ä»°Ëµ£¬Èç¹ûij¸ö ConcurrentExecution µÄʵÀý±»´´½¨Ê±£¬n ÊÇËüµÄÒ»¸ö²ÎÊý£¬ÄÇôÔÚÈκθø¶¨µÄʱ¼ä²»ÄÜÓг¬¹ý n ¸ö¼ÆËãÔÚÖ´ÐС£¸ù¾ÝÎÒÃÇÒÔÇ°µÄ·ÖÎö£¬¸Ã²ÎÊý¾ÍÒâζ"ÎÞÂÛÓжàÉÙ¸ö¹Ë¿ÍÔڵȴý£¬´ò¿ªµÄ½áËã¹ñ̨Êý²»Òª¶àÓÚ n ¸ö"¡£
int DoForAllObjects(int iNoOfObjects,long *ObjectArray, CONCURRENT_EXECUTION_ROUTINE pObjectProcessor, CONCURRENT_FINISHING_ROUTINE pObjectTerminated);
ÕâÊÇÔÚÕâÀﱻʵÏÖµÄΨһÓÐȤµÄ³ÉÔ±º¯Êý¡£DoForAllObjects µÄÖ÷Òª²ÎÊýÊÇÒ»¸ö¶ÔÏóµÄÊý×é¡¢Ò»¸ö´¦ÀíÆ÷º¯Êý¡¢ºÍÒ»¸öÖÕ½áÆ÷º¯Êý! ¡£¹ØÓÚ¶ÔÏóÍêȫûÓÐÇ¿ÖƵĸñʽ£»Ã¿´Î¸Ã´¦ÀíÆ÷±»µ÷ÓÃʱ£¬½«ÓÐÒ»¸ö¶ÔÏó±»´«µÝ¸øËü£¬¶øÇÒÍêÈ«Óɸô¦ÀíÆ÷À´½âÊͶÔÏó¡£µÚÒ»¸ö²ÎÊý iNoOfObjects£¬½ö½öÊÇÒª ConcurrentExecution ÖªµÀÔÚ¶ÔÏóÊý×éÖеÄÔªËØÊý¡£Çë×¢Ò⣬ÔÚµ÷Óà DoForAllObjects ʱ£¬Èç¹û¶ÔÏóÊý×éµÄ³¤¶ÈΪ 1£¬ÄÇôËüÓëµ÷Óà CreateThread ¾Í·Ç³£ÏàËÆ£¨ÓÐÒ»µã²»Í¬£¬ÄǾÍÊÇ CreateThread ²»½ÓÊÜÒ»¸öÖÕ½áÆ÷²ÎÊý£©¡£
DoForAllObjects µÄÓïÒåÈçÏ£º´¦ÀíÆ÷½«ÎªÃ¿Ò»¸ö¶ÔÏó¶øµ÷Ó᣶ÔÏó±»´¦ÀíµÄ˳Ðò²¢Î´Ö¸¶¨£»ËùÓÐÄܹ»µ£±£µÄÖ»ÊÇÿһ¸ö¶ÔÏ󶼽«ÔÚij¸öʱ¼ä±»´«µÝ¸ø´¦ÀíÆ÷¡£²¢·¢µÄ×î´ó¶ÈÊýÊÇÓÉ´«µÝ¸ø ConcurrentExecution ¶ÔÏóµÄ¹¹Ô캯ÊýµÄ²ÎÊýÀ´¾ö¶¨µÄ¡£
´¦ÀíÆ÷º¯Êý²»ÄÜ·ÃÎʹ²ÏíµÄÊý¾Ý£¬²¢ÇÒ²»Äܵ÷Óõ½ UI »ò×öÈκÎÆäËûÐèÒªÏÔʽ»òÒþʽµØ´®ÐвÙ×÷µÄÊÂÇ顣Ŀǰ£¬½ö´æÔÚÒ»¸ö´¦ÀíÆ÷º¯ÊýÄܹ»¶ÔËùÓеĶÔÏó¹¤×÷£»µ«ÊÇ£¬ÒªÊ¹Óô¦ÀíÆ÷Êý×éÀ´Ìæ´ú¸Ã´¦ÀíÆ÷²ÎÊý½«ÊǼòµ¥µÄ¡£
¸Ã´¦ÀíÆ÷µÄÔÐÍÈçÏ£º
typedef DWORD (WINAPI *CONCURRENT_EXECUTION_ROUTINE) (LPVOID lpParameterBlock);
µ±¸Ã´¦ÀíÆ÷ÒѾÍê³ÉÁËÔÚÒ»¸ö¶ÔÏóÉϵŤ×÷Ö®ºó£¬ÖÕ½áÆ÷º¯Êý½«Á¢¼´±»µ÷Óá£Óë´¦ÀíÆ÷²»Í¬£¬ÖÕ½áÆ÷º¯ÊýÊÇÔڸõ÷! Óú¯ÊýµÄ»·¾³Öб»´®Ðе÷Óõģ¬²¢ÇÒ¿ÉÒÔµ÷ÓÃËùÓеÄÀý³ÌºÍ·ÃÎʵ÷ÓóÌ! ÐòËùÄܹ» ·ÃÎʵÄËùÓÐÊý¾Ý¡£µ«ÊÇ£¬Ó¦¸ÃҪעÒâµÄÊÇ£¬ÖÕ½áÆ÷Ó¦¸Ã±»¾¡¿ÉÄܵØÓÅ»¯£¬ÒòΪÖÕ½áÆ÷Öеij¤¼ÆËã»áÓ°Ïì DoForAllObjects µÄÐÔÄÜ¡£Çë×¢Ò⣬¾¡¹ÜÖ»Òª´¦ÀíÆ÷½áÊøÁËÿһ¸ö¶ÔÏóÖÕ½áÆ÷¾Í»áÁ¢¼´±»µ÷Óã¬Ö±µ½×îºóÒ»¸ö¶ÔÏóÒѾ±»ÖÕ½á֮ǰ£¬DoForAllObjects ±¾Éí²¢Ã»Óзµ»Ø¡£
ÎÒÃÇΪʲôҪ¾ÀúÕâô¶àʹÓÃÖÕ½áÆ÷µÄÍ´¿à£¿ÎÒÃÇͬÑù¿ÉÒÔÈÃÿһ¸ö¼ÆËãÔÚ´¦ÀíÆ÷º¯ÊýµÄ×îÖÕ½áÊøʱִÐÐÖÕ½áÆ÷´úÂ룬ÊÇÂð£¿
ÕâÑù»ù±¾ÉÏÊÇ¿ÉÒԵģ»µ«ÊÇ£¬ÓбØҪǿµ÷ÖÕ½áÆ÷ÊÇÔÚµ÷Óà DoForAllObjectsµÄÏ̻߳·¾³Öб»µ÷Óõġ£ÕâÑùµÄÉè¼ÆʹÔÚÿһ¸ö¼ÆËã½øÈëʱ´¦ÀíËüÃǵĽá¹û¸ü¼ÓÈÝÒ×£¬¶øÎÞÐëµ£ÐÄͬ²½ÎÊÌâ¡£
ÖÕ½áÆ÷º¯ÊýµÄÔÐÍÈçÏ£º
typedef DWORD (WINAPI *CONCURRENT_FINISHING_ROUTINE) (LPVOID lpParameterBlock,LPVOID lpResultCode);
µÚÒ»¸ö²ÎÊýÊDZ»´¦ÀíµÄ¶ÔÏ󣬵ڶþ¸ö²ÎÊýÊÇ´¦ÀíÆ÷º¯ÊýÔڸöÔÏóÉϵĽá¹û¡£
DoForAllObjects µÄͬÀàÊÇ DoSerial£¬DoSerial Óë DoForAllObjects ¾ßÓÐÏàͬµÄ²ÎÊýÁÐ±í£¬µ«ÊǼÆËãÊDZ»ÒÔ´®ÐеÄ˳Ðò´¦ÀíµÄ£¬²¢ÇÒÒÔÁбíÖеĵÚÒ»¸ö¶ÔÏó¿ªÊ¼¡£
ConcurrentExecution µÄÄÚ²¿¹¤×÷
Çë×¢Òâ ±¾½ÚµÄÌÖÂÛÊǷdz£¼¼ÊõÐԵģ¬ËùÒÔ¼ÙÉèÄúÀí½âºÜ! ¶àÓÐ¹Ø Win32 Ïß³Ì API µÄ֪ʶ¡£Èç¹ûÄú¶ÔÈçºÎʹÓà ConcurrentExecution ÀàÀ´ÊÕ¼¯²âÊÔÊý¾Ý¸ü¼Ó¸ÐÐËȤ£¬¶ø²»ÊÇ¶Ô ConcurrentExecution::DoForAllObjects ÊÇÈçºÎ±»ÊµÏֵĸÐÐËȤ£¬ÄÇôÄúÏÖÔھͿÉÒÔÌøµ½ÏÂÃæµÄ"ʹÓà ConcurrentExecution À´ÊÔÑéÏß³ÌÐÔÄÜ"Ò»½Ú¡£
ÈÃÎÒÃÇ´Ó DoSerial ¿ªÊ¼£¬ÒòΪËüºÜ´ó³Ì¶ÈÉÏÊÇÒ»¸ö"²»·ÑÄÔ½îµÄ¼Ò»ï"£º
BOOL ConcurrentExecution::DoSerial(int iNoOfObjects,long *ObjectArray, CONCURRENT_EXECUTION_ROUTINE pProcessor, CONCURRENT_FINISHING_ROUTINE pTerminator) { for (int iLoop=0;iLoop<iNoOfObjects;iLoop++) { pTerminator((LPVOID)ObjectArray[iLoop],(LPVOID)pProcessor((LPVOID)ObjectArray[iLoop])); }; return TRUE;
};
Õâ¶Î´úÂëÖ»ÊÇÑ»·±éÀú¸ÃÊý×飬ÔÚÿһ´Îµü´úÖе÷Óô¦ÀíÆ÷£¬È»ºóÔÚ´¦ÀíÆ÷ºÍ¶ÔÏó±¾ÉíµÄ½á¹ûÉϵ÷ÓÃÖÕ½áÆ÷¡£¸ÉµÃ¼È¸É¾»ÓÖƯÁÁ£¬²»ÊÇÂð£¿
ÁîÈ˸ÐÐËȤµÄ³ÉÔ±º¯ÊýÊÇ DoForAllObjects¡£Õ§Ò»¿´£¬DoForAllObjects ËùÒª×öµÄҲûÓÐʲôÌرðµÄ--ÇëÇó²Ù×÷ϵͳ´´½¨ÎªÃ¿Ò»¸ö¼ÆËãÒ»¸öỊ̈߳¬²¢ÇÒÈ·±£ÖÕ½áÆ÷º¯ÊýÄܹ»±»ÕýÈ·µØµ÷Óᣵ«ÊÇ£¬! ÓÐÁ½¸öÎÊÌâʹµÃ DoForAllObjects ±ÈËüµÄ±íÃæÏÖÏóÒª¸´ÔÓ£ºµÚÒ»£¬µ±? ÆËãµÄÊýÄ ¿¶àÓÚ¿ÉÓõÄÏß³ÌÊýʱ£¬ConcurrentExecution µÄÒ»¸öʵÀýËù´´½¨µÄ"²¢·¢µÄ×î´ó¶ÈÊý"²ÎÊý¿ÉÄÜÐèҪһЩ¸½¼ÓµÄ¼Ç¼(bookkeeping)¡£µÚ¶þ£¬Ã¿Ò»¸ö¼ÆËãµÄÖÕ½áÆ÷º¯Êý¶¼ÊÇÔÚµ÷Óà DoForAllObjects µÄÏ̵߳ÄÉÏÏÂÎÄÖб»µ÷Óõģ¬¶ø²»ÊÇÔڸüÆËãÔËÐÐËù´¦µÄÏß³ÌÉÏÏÂÎÄÖб»µ÷Óõģ»²¢ÇÒ£¬ÖÕ½áÆ÷ÊÇÔÚ´¦ÀíÆ÷½áÊøÖ®ºóÁ¢¿Ì±»µ÷Óõġ£Òª´¦ÀíÕâЩÎÊÌ⻹ÊÇÐèÒªºÜ¶à¼¼Çɵġ£
ÈÃÎÒÃÇÉîÈëµ½´úÂëÖУ¬¿´¿´¾¿¾¹ÊÇÔõôÑùµÄ¡£¸Ã¶Î´úÂëÊÇ´ÓÎļþ Thrdlib.cpp Öм̳ÐÀ´µÄ£¬µ«ÊÇΪÁËÇå³ýÆð¼û£¬ÒѾ±»¾«¼òÁË£º
int ConcurrentExecution::DoForAllObjects(int iNoOfObjects,long *ObjectArray, CONCURRENT_EXECUTION_ROUTINE pObjectProcessor, CONCURRENT_FINISHING_ROUTINE pObjectTerminated) { int iLoop,iEndLoop; DWORD iThread; DWORD iArrayIndex; DWORD dwReturnCode; DWORD iCurrentArrayLength=0; BOOL bWeFreedSomething; char szBuf[70];
m_iCurrentNumberOfThreads=iNoOfObjects;
HANDLE *hPnt=(HANDLE *)VirtualAlloc(NULL,m_iCurrentNumberOfThreads*sizeof(HANDLE) ,MEM_COMMIT,PAGE_READWRITE); for(iLoo! p=0;iLoop<m_iCurrentNumberOfThreads;iLoop++) hPnt[iLoop] = CreateThread(NULL,0,pObjectProcessor,(LPVOID)ObjectArray[iLoop], CREATE_SUSPENDED,(LPDWORD)&iThread);
Ê×ÏÈ£¬ÎÒÃÇΪÿһ¸ö¶ÔÏó´´½¨µ¥¶ÀµÄÏ̡߳£ÒòΪÎÒÃÇʹÓà CREATE_SUSPENDED À´´´½¨¸ÃỊ̈߳¬ËùÒÔ»¹Ã»ÓÐÏ̱߳»Æô¶¯¡£ÁíÒ»ÖÖ·½·¨ÊÇÔÚÐèҪʱ´´½¨Ã¿Ò»¸öÏ̡߳£ÎÒ¾ö¶¨²»Ê¹ÓÃÕâÖÖÌæ´úµÄ²ßÂÔ£¬ÒòΪÎÒ·¢ÏÖµ±ÔÚÒ»¸öͬʱÔËÐÐÁ˶à¸öÏ̵߳ÄÓ¦ÓóÌÐòÖе÷ÓÃʱ£¬ CreateThread µ÷ÓÃÊǷdz£À˷ѵģ»ÕâÑù£¬Í¬ÔÚÔËÐÐʱ´´½¨Ã¿Ò»¸öÏß³ÌÏà±È£¬ÔÚ´Ëʱ´´½¨Ï̵߳ĿªÏú½«¸ü¼ÓÈÝÒ×½ÓÊÜ£¬
for (iLoop = 0; iLoop < m_iCurrentNumberOfThreads; iLoop++) { HANDLE hNewThread; bWeFreedSomething=FALSE; // Èç¹ûÊý×éΪ¿Õ£¬·ÖÅäÒ»¸ö slot ºÍ boogie¡£ if (!iCurrentArrayLength) { iArrayIndex = 0; iCurrentArrayLength=1; } else { // Ê×ÏÈ£¬¼ì²éÎÒÃÇÊÇ·ñ¿ÉÒÔÖظ´Ê¹ÓÃÈÎºÎµÄ slot¡£ÎÒÃÇÏ£ÍûÔÚ²éÕÒÒ»¸öÐ嵀 slot ֮ǰÊ×ÏÈ// ×öÕâÏ×÷£¬ÕâÑùÎÒÃǾͿÉÒÔÁ¢¿Ìµ÷ÓøþÍÏ̵߳ÄÖÕ½áÆ÷... iArrayIndex=WaitForMultipleObjects(iCurrentArrayLength, m_hThrea! dArray,FALSE,0); if (iArrayIndex==WAIT_TIMEOUT) // no slot ! free...< br>{ { if (iCurrentArrayLength >= m_iMaxArraySize) { iArrayIndex= WaitForMultipleObjects(iCurrentArrayLength, m_hThreadArray,FALSE,INFINITE); bWeFreedSomething=TRUE; } else // ÎÒÃÇ¿ÉÒÔÊÍ·Åij´¦µÄÒ»¸ö slot£¬ÏÖÔÚ¾ÍÕâô×ö... { iCurrentArrayLength++; iArrayIndex=iCurrentArrayLength-1; }; // Else iArrayIndex points to a thread that has been nuked }; } else bWeFreedSomething = TRUE; }; // ÔÚÕâÀiArrayIndex °üº¬Ò»¸öÓÐЧµÄË÷ÒýÒԴ洢еÄÏ̡߳£ hNewThread = hPnt[iLoop]; ResumeThread(hNewThread); if (bWeFreedSomething) { GetExitCodeThread(m_hThreadArray[iArrayIndex],&dwReturnCode); //´íÎó CloseHandle(m_hThreadArray[iArrayIndex]); pObjectTerminated((void *)m_hObjectArray[iArrayIndex],(void *)dwReturnCode); }; m_hThreadArray[iArrayIndex] = hNewThread; m_hObjectArray[iArrayIndex] = ObjectArray[iLoop]; }; // Ñ»·½áÊø
DoForAllObjects µÄºËÐÄÊÇ hPnt£¬ËüÊÇÒ»¸ö¶ÔÏóÊý×飬ÕâЩ¶ÔÏóÊǵ± ConcurrentExecution ¶Ô? ó±»¹¹Ôìʱ·ÖÅäµÄ¡£¸ÃÊý×éÄܹ»ÈÝÄÉ×î´óÊýÄ¿µÄỊ̈߳¬´Ë×î´óÊýÄ¿ÓëÔÚ¹¹Ô캯ÊýÖÐÖ¸¶¨µÄ×î´ó²¢·¢¶ÈÊýÏà¶ÔÓ¦£»Òò´Ë£¬¸ÃÊý×éÖеÄÿһ¸öÔªËض¼ÊÇÒ»¸?quot;slot"£¬²¢ÓÐÒ»¸ö¼ÆËã¾ÓÓÚÖ®ÖС£
¹ØÓÚ¾ö¶¨ÈçºÎÌî³äºÍÊÍ·ÅµÄ slots Ëã·¨ÈçÏ£º¸Ã¶ÔÏóÊý×éÊÇ´ÓÍ·µ½Î²±éÀúµÄ£¬²¢ÇÒ¶ÔÓÚÿһ¸ö¶ÔÏó£¬ÎÒÃǶ¼×öÈçϵÄÊÂÇ飺Èç¹ûÉÐδÓÐ slot ÒѾ±»Ìî³ä£¬ÎÒÃÇʹÓõ±Ç°µÄ¶ÔÏóÀ´Ìî³ä¸ÃÊý×éÖеĵÚÒ»¸ö slot£¬²¢ÇÒ¼ÌÐøÖ´Ðн«Òª´¦Àíµ±Ç°¶ÔÏóµÄÏ̡߳£Èç¹ûÖÁÉÙÓÐÒ»¸ö slot ±»Ê¹Óã¬ÎÒÃÇʹÓà WaitForMultipleObjects º¯ÊýÀ´¾ö¶¨ÊÇ·ñÓÐÕýÔÚÔËÐеÄÈκμÆËãÒѾ½áÊø£»Èç¹ûÊÇ£¬ÎÒÃÇÔڸöÔÏóÉϵ÷ÓÃÖÕ½áÆ÷£¬²¢ÇÒΪжÔÏó"ÖØÓÃ"¸Ã slot¡£Çë×¢Ò⣬ÎÒÃÇÒ²¿ÉÒÔÊ×ÏÈÌî³äÿһ¸ö¿ÕÏÐµÄ slot£¬Ö±µ½Ã»ÓÐÊ£ÓàµÄ slots Ϊֹ£¬È»ºó¿ªÊ¼Ìî³ä¿ÕµÄ slot¡£µ«ÊÇ£¬Èç¹ûÎÒÃÇÕâÑù×öÁË£¬ÄÇô¿Õ³ö slot µÄÖÕ½áÆ÷º¯Êý½«²»»á±»µ÷Óã¬Ö±µ½ËùÓÐµÄ slot ¶¼ÒѾ±»Ìî³ä£¬ÕâÑù¾ÍÎ¥·´ÁËÎÒÃÇÓйص±´¦ÀíÆ÷½áÊøÒ»¸ö¶ÔÏóʱ£¬ÖÕ½áÆ÷Á¢¿Ì±»µ÷ÓõÄÒªÇó¡£
×îºó£¬»¹ÓÐûÓпÕÏÐ slot µÄÇé¿ö£¨¾ÍÊÇ˵£¬µ±Ç°¼¤»îµÄÏß³ÌÊýµÈÓÚ ConcurrentExecution ¶ÔÏóËùÔÊÐíµÄ×î´ó²¢·¢¶ÈÊý£©¡£ÔÚÕâÖÖÇé¿öÏ£¬WaitForMultipleObjects ½«? »Ôٴε÷ÓÃÒÔʹµ?DoForAllObjects ´¦ÓÚ"˯Ãß"״̬£¬Ö±µ½! ÓÐÒ»¸ö s lot ¿Õ³ö£»Ö»ÒªÕâÖÖÇé¿öÒ»·¢Éú£¬ÖÕ½áÆ÷¾Í±»ÔÚ¿Õ³ö slot µÄ¶ÔÏóÉϵ÷Ó㬲¢ÇÒ¹¤×÷ÓÚµ±Ç°¶ÔÏóµÄÏ̱߳»¼ÌÐøÖ´ÐС£
ÖÕÓÚ£¬ËùÓеļÆËãҪô¶¼ÒѾ½áÊø£¬ÒªÃ´½«Õ¼ÓжÔÏóÊý×éÖÐµÄ slot¡£ÏÂÁеĴúÂ뽫»á´¦ÀíËùÓÐÊ£ÓàµÄỊ̈߳º
iEndLoop = iCurrentArrayLength; for (iLoop=iEndLoop;iLoop>0;iLoop--) { iArrayIndex=WaitForMultipleObjects(iLoop, m_hThreadArray,FALSE,INFINITE); if (iArrayIndex==WAIT_FAILED) { GetLastError(); _asm int 3; // ÕâÀïÒª×öһЩ´ÏÃ÷µÄÊÂ... }; GetExitCodeThread(m_hThreadArray[iArrayIndex],&dwReturnCode); // ´íÎó£¿ if (!CloseHandle(m_hThreadArray[iArrayIndex])) MessageBox(GetFocus(),"Cant delete thread!","",MB_OK); // ʹËü¸üºÃ...
pObjectTerminated((void *)m_hObjectArray[iArrayIndex], (void *)dwReturnCode); if (iArrayIndex==iLoop-1) continue; // ÕâÀïºÜºÃ£¬Ã»ÓÐÐèÒªÏòºóÌî³ä m_hThreadArray[iArrayIndex]=m_hThreadArray[iLoop-1]; m_hObjectArray[iArrayIndex]=m_hObjectArray[iLoop-1]; };
×îºó£¬Çå³ý£º !
if (hPnt) VirtualFree(hPnt,m_iCurrentNumberOfThreads*sizeof(HANDLE), MEM_DECOMMIT);
return iCurrentArrayLength;
};
ʹÓà ConcurrentExecution À´ÊÔÑéÏß³ÌÐÔÄÜ
ÐÔÄܲâÊԵķ¶Î§ÈçÏ£º²âÊÔÓ¦ÓóÌÐò Threadlibtest.exe µÄÓû§¿ÉÒÔÖ¸¶¨ÊÇ·ñ²âÊÔ»ùÓÚ CPU µÄ»ò»ùÓÚ I/O µÄ¼ÆËã¡¢Ö´ÐжàÉÙ¸ö¼ÆËã¡¢¼ÆËãµÄʱ¼äÓж೤¡¢¼ÆËãÊÇÈçºÎÅÅÐòµÄ£¨ÎªÁ˲âÊÔ×îÔãµÄÇé¿öÓëËæ»úÑÓ³Ù£©£¬ÒÔ¼°¼ÆËãÊDZ»²¢·¢Ö´Ðл¹ÊÇ´®ÐÐÖ´ÐС£
ΪÁËÏû³ýÒâÍâµÄ½á¹û£¬Ã¿Ò»¸ö²âÊÔ¿ÉÒÔ±»Ö´ÐÐÊ®´Î£¬È»ºó½«Ê®´ÎµÄ½á¹ûÄÃÀ´Æ½¾ù£¬ÒÔ²úÉúÒ»¸ö¸ü¼Ó¿ÉÐŵĽá¹û¡£
ͨ¹ýÑ¡Ôñ²Ëµ¥Ñ¡Ïî "Run entire test set"£¬Óû§¿ÉÒÔÇëÇóÔËÐÐËùÓвâÊÔ±äÁ¿µÄ±äÐΡ£ÔÚ²âÊÔÖÐʹÓõļÆË㳤¶ÈÔÚ»ù´¡Öµ 10 ºÍ 3,500 ms Ö®¼ä±ä¶¯£¨ÎÒÒ»»á¶ù½«ÌÖÂÛÕâÒ»ÎÊÌ⣩£¬¼ÆËãµÄÊýÄ¿ÔÚ 2 ºÍ 20 Ö®¼ä±ä»¯¡£Èç¹ûÔÚÔËÐиòâÊԵļÆËã»úÉÏ°²×°ÁË Microsoft Excel£¬Threadlibtest.exe ½«»á°Ñ½á¹ûת´¢ÔÚÒ»¸ö Microsoft Excel ¹¤×÷±í£¬¸Ã¹¤×÷±íλÓÚ C:\Temp\Values.xls¡£ÔÚÈκÎÇé¿öϽá¹ûÖµÒ²½«»á±»±£´æµ½Ò»¸ö´¿Îı¾ÎļþÖУ¬¸ÃÎļþλÓÚ C:\Temp\Results.fil¡£Çë×¢Ò⣬ÎÒ¶ÔÓÚÐÒéÎļþµÄλÖÃʹÓÃÁËÓ²! ±àÂëµÄ·½Ê½£¬´¿´âÊÇÀÁ¶èÐÐΪ£»Èç¹ûÄúÐèÒªÔÚÄúµÄ¼ÆËã»úÉÏÖØÐÂÉú³É²â! ÊÔ½á¹û£¬ ²¢ÇÒÐèÒªÖ¸¶¨Ò»¸ö²»Í¬µÄλÖã¬ÄÇôֻÐèÒªÖØбàÒëÉú³É¸Ã¹¤³Ì£¬¸Ä±äÎļþ Threadlibtestview.cpp µÄ¿ªÍ·²¿·ÖµÄ TEXTFILELOC ºÍ SHEETFILELOC ±êʶ·ûµÄÖµ¼´¿É¡£
ÇëÀμǣ¬ÔËÐÐÕû¸öµÄ²âÊÔ³ÌÐò½«×ÜÊÇÒÔ×îÔãµÄÇé¿öÀ´ÅÅÐò¼ÆË㣨¾ÍÊÇ˵£¬Ö´ÐеÄ˳ÐòÊÇ´®Ðеģ¬×µÄ¼ÆË㽫±»Ê×ÏÈÖ´ÐУ¬Æäºó¸úËæ×ŵڶþ³¤µÄ¼ÆË㣬ȻºóÒÔ´ÎÀàÍÆ£©¡£ÕâÖÖ·½°¸ÎþÉüÁË´®ÐÐÖ´ÐеÄÁé»îÐÔ£¬ÒòΪ²¢·¢Ö´ÐеÄÏìӦʱ¼äÔÚÒ»¸ö·Ç×îÔãµÄ·½°¸ÏÂҲûÓиı䣬¶ø¸Ã´®ÐÐÖ´ÐеÄÏìӦʱ¼äÊÇÓпÉÄÜÌá¸ßµÄ¡£
ÕýÈçÎÒÇ°ÃæËùÌáµ½µÄ£¬ÔÚÒ»¸öʵ¼ÊµÄ·½°¸ÖУ¬ÄúÓ¦¸Ã·ÖÎöÿһ¸ö¼ÆËãµÄʱ¼äÊÇ·ñÊÇ¿ÉÒÔÔ¤²âµÄ¡£
ʹÓà ConcurrentExecution ÀàÀ´ÊÕ¼¯ÐÔÄÜÊý¾ÝµÄ´úÂëλÓÚ Threadlibtestview.cpp ÖС£Ê¾ÀýÓ¦ÓóÌÐò±¾Éí (Threadlibtest.exe) ÊÇÒ»¸öÕæÕýµÄµ¥Îĵµ½çÃæ (SDI) µÄ MFC Ó¦ÓóÌÐò¡£ËùÓÐÓëʾÀýÓйصĴúÂ붼פÁôÔÚ view ÀàµÄʵÏÖ CThreadLibTestView ÖУ¬ËüÊÇ´Ó CEasyOutputView ¼Ì³Ð¶øÀ´µÄ¡££¨ÓйضԸÃÀàµÄÌÖÂÛ£¬Çë²Î¿¼"Windows NT Security in Theory and Practice"¡££©ÕâÀï²¢²»°üº¬¸ÃÀàÖÐËùÓеÄÓÐȤ´úÂ룬Ëù°üº¬µÄ´ó²¿·ÖÊÇÆäÊý×Öͳ¼Æ²¿·ÖºÍÓû§½çÃæ´¦Àí²¿·Ö¡£Ö´ÐвâÊÔÖÐµÄ "meat" ÔÚ ! CThreadLibTestView::ExecuteTest ÖУ¬½«Ö´ÐÐÒ»¸ö²âÊÔÔËÐÐÖÜÆÚ¡£ÏÂÃæÊÇÓÐ¹Ø CThreadLibTestView::ExecuteTest µÄ¼òÂÔ´úÂ룺
void CThreadlibtestView::ExecuteTest() { ConcurrentExecution *ce; bCPUBound=((m_iCompType&CT_IOBOUND)==0); // È«¾Ö... ce = new ConcurrentExecution(25); if (!QueryPerformanceCounter(&m_liOldVal)) return; // »ñµÃµ±Ç°Ê±¼ä¡£ if (!m_iCompType&CT_IOBOUND) timeBeginPeriod(1); if (m_iCompType&CT_CONCURRENT) m_iThreadsUsed=ce->DoForAllObjects(m_iNumberOfThreads, (long *)m_iNumbers, (CONCURRENT_EXECUTION_ROUTINE)pProcessor, (CONCURRENT_FINISHING_ROUTINE)pTerminator); else ce->DoSerial(m_iNumberOfThreads, (long *)m_iNumbers, (CONCURRENT_EXECUTION_ROUTINE)pProcessor, (CONCURRENT_FINISHING_ROUTINE)pTerminator); if (!m_iCompType&CT_IOBOUND) timeEndPeriod(1); delete(ce); < ÆäËûµÄ´úÂëÔÚÒ»¸öÊý×éÖÐÅÅÐò½á¹û£¬ÒÔ¹© Excel ´¦Àí...> }
¸Ã¶Î´úÂëÊ×ÏÈ´´½¨Ò»¸ö ConcurrentExecution ÀàµÄ¶ÔÏó£¬È»ºó£¬È¡Ñùµ±Ç°Ê±¼ä£¬£¨! ÓÃÓÚͳ¼Æ¼ÆËãËùÏûºÄµÄʱ¼äºÍÏìӦʱ¼ä£©£¬²¢ÇÒ£¬¸ù¾ÝËùÇëÇóµÄÊÇ´®ÐÐ! Ö´Ðл¹ÊÇ ²¢·¢Ö´ÐУ¬·Ö±ðµ÷Óà ConcurrentExecution ¶ÔÏó DoSerial »ò DoForAllObjects ³ÉÔ±¡£Çë×¢Ò⣬¶ÔÓÚµ±Ç°µÄÖ´ÐÐÎÒÇëÇó×î´ó²¢·¢¶ÈÊýΪ 25£»Èç¹ûÄúÏëÒªÔËÐÐÓжàÓÚ 25 ¸ö¼ÆËãµÄ²âÊÔ³ÌÐò£¬ÄÇôÄúÓ¦¸ÃÌá¸ß¸ÃÖµ£¬Ê¹Ëü´óÓÚ»òµÈÓÚÔËÐÐÄúµÄ²âÊÔ³ÌÐòËùÐèÒªµÄ×î´ó²¢·¢Êý¡£
ÈÃÎÒÃÇ¿´Ò»Ï´¦ÀíÆ÷ºÍÖÕ½áÆ÷£¬ÒԵõ½¾«È·²âÁ¿µÄ½á¹û£º
extern "C" { long WINAPI pProcessor(long iArg) { PTHREADBLOCKSTRUCT ptArg=(PTHREADBLOCKSTRUCT)iArg; BOOL bResult=TRUE; int iDelay=(ptArg->iDelay); if (bCPUBound) { int iLoopCount; iLoopCount=(int)(((float)iDelay/1000.0)*ptArg->tbOutputTarget->m_iBiasFactor); QueryPerformanceCounter(&ptArg->liStart); for (int iCounter=0; iCounter<iLoopCount; iCounter++); } else { QueryPerformanceCounter(&ptArg->liStart); Sleep(ptArg->iDelay); }; return bResult; }
long WINAPI pTerminator(long iArg, long iReturnCode) { PTHREADBLOCKSTRUCT ptArg=(PTHREADBLOCKSTRUCT)iArg; QueryPerformanceCounter(&ptArg->liFini! sh); ptArg->iEndOrder=iEndIndex++; return(0); }
}
´¦ÀíÆ÷Ä£ÄâÒ»¸ö¼ÆË㣬Æ䳤¶ÈÒѾ±»·Åµ½Ò»¸öÓë¼ÆËãÓйصÄÊý¾Ý½á¹¹ THREADBLOCKSTRUCT ÖС£THREADBLOCKSTRUCT ±£³Ö×ÅÓë¼ÆËãÓйصÄÊý¾Ý£¬ÈçÆäÑÓ³ÙºÍÖÕֹʱ¼ä£¨ÒÔÐÔÄܼÆÊý"µÎ´ð"À´ºâÁ¿£©£¬ÒÔ¼°·´ÏòÖ¸Õ룬ָÏòʵÓû¯¸Ã½á¹¹µÄÊÓͼ(view)¡£
ͨ¹ý¼òµ¥µÄʹ¼ÆËã"˯Ãß"Ö¸¶¨µÄʱ¼ä¾Í¿ÉÒÔÄ£Äâ»ùÓÚI/OµÄ¼ÆËã¡£»ùÓÚ CPUµÄ¼ÆË㽫½øÈëÒ»¸ö¿ÕµÄ for Ñ»·¡£ÕâÀïµÄһЩעÊÍÊÇΪÁË°ïÖúÀí½â´úÂëµÄ¹¦ÄÜ£º¼ÆËãÊÇ»ùÓÚ CPU µÄ£¬²¢ÇÒ¼Ù¶¨ÆäÖ´ÐÐʱ¼äΪָ¶¨µÄºÁÃëÊý¡£ÔÚ±¾²âÊÔ³ÌÐòµÄÔçÆÚ°æ±¾ÖУ¬ÎÒ½ö½öÊÇÒª for Ñ»·Ö´ÐÐ×ã¹»¶àµÄ´ÎÊýÒÔÂú×ãÖ¸¶¨µÄÑÓ³ÙµÄÐèÇ󣬶ø²»¿¼ÂÇÊý×ÖµÄʵ¼Êº¬Òå¡££¨¸ù¾ÝÏà¹ØµÄ´úÂ룬¶ÔÓÚ»ùÓÚI/OµÄ¼ÆËã¸ÃÊý×Öʵ¼ÊÒâζןÁÃ룬¶ø¶ÔÓÚ»ùÓÚCPUµÄ¼ÆË㣬¸ÃÊý×ÖÔòÒâζ×ŵü´ú´ÎÊý¡££©µ«ÊÇ£¬ÎªÁËÄܹ»Ê¹Óþø¶Ôʱ¼äÀ´±È½Ï»ùÓÚCPUµÄ¼ÆËãºÍ»ùÓÚI/OµÄ¼ÆË㣬ÎÒ¾ö¶¨ÖØдÕâ¶Î´úÂ룬ÕâÑùÎÞÂÛ¶ÔÓÚ»ùÓÚCPUµÄ¼ÆË㻹ÊÇ»ùÓÚI/OµÄ¼ÆË㣬Óë¼ÆËãÓйصÄÑÓ³Ù¶¼ÊÇÒÔºÁÃë²âÁ¿¡£
ÎÒ·¢ÏÖ¶ÔÓÚ¾ßÓÐÖ¸¶¨µÄ¡¢Ô¤Ïȶ¨Òåʱ¼ä³¤¶ÈµÄ»ùÓÚCPUµÄ¼ÆË㣬Ҫ±àд´úÂëÀ´Ä£ÄâËü²¢²»ÊÇÒ»¼þ¼òµ¥µÄÊÂÇé¡£ÔÒòÊÇÕâ? ùµÄ´úÂë±¾Éí²»Äܲéѯϵͳʱ¼ä£¬ÒòΪËùÒý·¢µÄµ÷ÓóÙÔ綼»á½»³?CPU? ¬¶øÕâÎ¥± ³ÁË»ùÓ?CPU µÄ¼ÆËãµÄÒªÇó¡£ÊÔͼʹÓÃÒì²½¶àýÌåʱÖÓʼþͬÑùûÓеõ½ÂúÒâµÄЧ¹û£¬ÔÒòÊÇ Windows NT ϼÆʱÆ÷·þÎñµÄ¹¤×÷·½Ê½¡£ÉèÖÃÁËÒ»¸ö¶àýÌå¼ÆʱÆ÷µÄÏß³Ìʵ¼ÊÉϱ»¹ÒÆð£¬Ö±µ½¸Ã¼ÆʱÆ÷»Øµ÷±»µ÷Óã»Òò´Ë£¬»ùÓÚ CPU µÄ¼ÆËãͻȻ±ä³ÉÁË»ùÓÚ I/O µÄ²Ù×÷ÁË¡£
ÓÚÊÇ£¬×îºóÎÒʹÓÃÁËÒ»¸öÓеã¶ùµÍÁӵļ¼ÇÉ£ºCThreadLibTestView::OnCreate ÖеĴúÂëÖ´ÐÐ 100 ´ÎÑ»·´Ó 1 µ½ 100,000 ¼ÆÊý£¬²¢ÇÒÈ¡Ñùͨ¹ý¸ÃÑ»·ËùÐèÒªµÄƽ¾ùʱ¼ä¡£½á¹û±»±£´æÔÚ³ÉÔ±±äÁ¿ m_iBiasFactor ÖУ¬¸Ã³ÉÔ±±äÁ¿ÊÇÒ»¸ö¸¡µãÊý£¬ËüÔÚ´¦ÀíÆ÷º¯ÊýÖб»Ê¹ÓÃÀ´¾ö¶¨ºÁÃëÈçºÎ±»"·Òë"³Éµü´ú´ÎÊý¡£²»ÐÒµÄÊÇ£¬ÒòΪ²Ù×÷ϵͳµÄ¸ß¶ÈÏ·¾çÐÔµÄÌìÐÔ£¬Òª¾ö¶¨Êµ¼ÊÉÏÔËÐÐÒ»¸öÖ¸¶¨³¤¶ÈµÄ¼ÆËãÒªµü´ú¶àÉٴθø¶¨µÄÑ»·ÊÇÀ§Äѵġ£µ«ÊÇ£¬ÎÒ·¢ÏָòßÂÔÔÚ¾ö¶¨»ùÓÚCPUµÄ²Ù×÷µÄ¼ÆËãʱ¼ä·½Ã棬Íê³ÉÁ˷dz£¿ÉÐŵŤ×÷¡£
×¢Òâ Èç¹ûÄúÖØбàÒëÉú³É¸Ã²âÊÔÓ¦ÓóÌÐò£¬ÇëСÐÄʹÓÃ×îÓÅ»¯Ñ¡Ïî¡£Èç¹ûÄúÖ¸¶¨ÁË "Minimize execution time" ÓÅ»¯£¬Ôò±àÒë³ÌÐò½«¼ì²â¾ßÓпյÄÖ÷ÌåµÄ for Ñ»·£¬²¢ÇÒɾ³ýÕâЩѻ·¡£
ÖÕ½áÆ÷·Ç³£¼òµ¥£ºµ±Ç°Ê±¼ä±»È¡Ñù²¢±£´æÔÚ¼ÆËãµÄ THREADBLOCKSTRUCT ÖС£ÔÚ²âÊÔ½áÊøÖ®ºó£¬¸Ã´úÂë¼ÆËã? ´Ð?ExecuteTest µÄʱ¼äºÍÖÕ½áÆ÷Ϊÿһ¸ö¼ÆËãËùµ÷ÓõÄʱ¼äÖ®¼äµÄ²îÒ졣Ȼºó£¬ËùÓмÆËãËùÏûºÄµÄʱ¼äÓÉËùÓÐÒÑÍê³ÉµÄ¼ÆËãÖÐ×îºóÒ»¸ö¼ÆËãÍê³ÉʱËùÏûºÄµÄʱ¼äËù¾ö¶¨£¬¶øÏìӦʱ¼äÔòÊÇÿһ¸ö¼ÆËãµÄÏìӦʱ¼äµÄƽ¾ùÖµ£¬ÕâÀÿһ¸öÏìӦʱ¼ä£¬Í¬Ñù£¬¶¨ÒåΪ´Ó²âÊÔ¿ªÊ¼¸ÃÏß³ÌÏûºÄµÄʱ¼ä³ýÒÔ¸ÃÏ̵߳ÄÑÓ³ÙÒò×Ó¡£Çë×¢Ò⣬ÖÕ½áÆ÷ÔÚÖ÷Ïß³ÌÉÏÏÂÎÄÖд®Ðл¯µÄÔËÐУ¬ËùÒÔÔÚ¹²ÏíµÄ iEndIndex ±äÁ¿ÉϵĵÝÔöÖ¸ÁîÊÇ°²È«µÄ¡£
ÕâЩʵ¼Ê¾ÍÊDZ¾²âÊÔµÄÈ«²¿£»ÆäÓàµÄ²¿·ÖÔòÖ÷ÒªÊÇΪ²âÊÔµÄÔËÐÐÉèÖÃһЩ²ÎÊý£¬ÒÔ¼°¶Ô½á¹ûÖ´ÐÐһЩÊýѧ¼ÆËã¡£Ìî³ä½á¹ûµ½ Microsoft Excel ¹¤×÷µ¥ÖеÄÏà¹ØÂß¼½«ÔÚ"Interacting with Microsoft Excel: A Case Study in OLE Automation."Ò»ÎÄÖÐÌÖÂÛ¡£
½á¹û
Èç¹ûÄúÏëÒªÔÚÄúµÄ¼ÆËã»úÉÏÖØд´½¨¸Ã²âÊÔ½á¹û£¬ÄúÐèÒª×öÒÔϵÄÊÂÇ飺
Èç¹ûÄúÐèÒª¸Ä±ä²âÊÔ²ÎÊý£¬ÀýÈç×î´ó¼ÆËãÊý»òÐÒéÎļþµÄλÖã¬Çë±à¼ THRDPERF ʾÀý¹¤³ÌÖÐµÄ Threadlibtestview.cpp£¬È»ºóÖØбàÒëÉú³É¸ÃÓ¦ÓóÌÐò¡££¨Çë×¢Ò⣬Ҫ±àÒëÉú³É¸ÃÓ¦ÓóÌÐò£¬ÄúµÄ¼ÆËã»úÐèÒª¶Ô³¤ÎļþÃûµÄÖ§³Ö¡££©
ÇëÈ·±£Îļþ Thrdlib.dll ÔÚÒ»¸ö Threadlibtest.exe Äܹ»Á´½Óµ½ËüµÄλÖᣠ<br! > Èç¹ûÄúÏëҪʹÓà Microsoft Excel À´²é¿´²âÊԵĽá¹û£¬ÇëÈ·¶¨ M! icrosoft Excel ÒѾÕýÈ·µØ±»°²×°ÔÚÔËÐиòâÊԵļÆËã»úÉÏ¡£
´Ó Windows 95 »ò Windows NT Ö´ÐÐ Threadlibtest.exe£¬²¢ÇÒ´Ó"Run performance tests"²Ëµ¥Ñ¡Ôñ"Run entire test set"¡£Õý³£Çé¿öÏ£¬²âÊÔÔËÐÐÒ»´ÎÒª»¨·Ñ¼¸¸öСʱ²ÅÄÜÍê³É¡£
ÔÚ²âÊÔ½áÊøÖ®ºó£¬¼ì²é½á¹ûʱ£¬¼È¿ÉÒÔʹÓÃÆÕͨÎı¾ÐÒéÎļþ C:\Temp\Results.fil £¬Ò²¿ÉÒÔʹÓù¤×÷µ¥Îļþ C:\Temp\Values.xls¡£Çë×¢Ò⣬Microsoft Excel µÄ×Ô¶¯»¯£¨automation£©Âß¼²¢²»×Ô¶¯µØΪÄú´ÓÔʼÊý¾ÝÉú³Éͼ±í£¬ÎÒʹÓÃÁ˼¸¸öºêÀ´ÖØÐÂÅÅÁиýá¹û£¬²¢ÇÒΪÄúÉú³ÉÁËͼ±í¡£ÎÒÔ÷ºÞÊý×Ö£¨number crunching£©£¬µ«ÊÇÎÒ±ØÐè³ÆÔÞ Microsoft Excel£¬ÒòΪ¼´Ê¹ÏóÎÒÒ»ÑùµÄ¹¤×÷±íÍýÏë¿ñ£¨spreadsheet-paranoid£©£¬Ò²¿ÉÒÔÌṩÕâÑùƯÁÁµÄÓû§½çÃ棬ÔÚ¼¸·ÖÖÓÖ®ÄڰѼ¸ÁÐÊý¾Ý×°ÈëÓÐÓõÄͼ±í¡£
ÎÒËùÕ¹ÏֵIJâÊÔ½á¹ûÊÇÔÚÒ»¸ö 486/33 MHz µÄ´øÓÐ 16 MB RAM µÄϵͳÊÕ¼¯¶øÀ´µÄ¡£¸Ã¼ÆËã»úͬʱ°²×°ÁË Windows NT (3.51 °æ) ºÍ Windows 95£»ÕâÑù£¬ÔÚÁ½¸ö²Ù×÷ϵͳÉϵIJ»Í¬²âÊÔ½á¹û¾ÍÊǿɱȵÄÁË£¬ÒòΪËüÃÇ»ùÓÚͬÑùµÄÓ²¼þϵͳ¡£
ÄÇô£¬ÏÖÔÚÈÃÎÒÃÇÀ´½âÊÍÕâЩֵ¡£ÕâÀïÊÇ×ܽá¼ÆËã½á¹ûµÄͼ±í£»ºóÃæÓÐÆä½âÊÍ¡£¸Ãͼ±íÓ¦¸Ã! ÕâÑùÀ´¿´£ºÃ¿Ò»¸öͼ±íµÄ x ÖáÓÐ 6 ¸öÖµ£¨³ýÁËÓйس¤¼ÆËãµÄÏûºÄʱ¼ä±í£¬¸Ã±í½öº¬ÓÐ 5 ¸öÖµ£¬ÕâÊÇÒòΪÔÚÎҵIJâÊÔÔËÐÐʱ£¬¶ÔÓڷdz£³¤µÄ¼ÆËã¼ÆʱÆ÷Òç³öÁË£©¡£Ò»¸öÖµ´ú±í¶à¸ö¼ÆË㣻ÎÒÒÔ 2¡¢5¡¢8¡¢11¡¢14 ºÍ 17 ¸ö¼ÆËãÀ´ÔËÐÐÿһ¸ö²âÊÔ¡£ÔÚ Microsoft Excel ½á¹û¹¤×÷±íÖУ¬Äú½«»áÕÒµ½¶ÔÓÚ»ùÓÚCPUµÄ¼ÆËãºÍ»ùÓÚI/OµÄ¼ÆËãµÄÏ̵߳ÄÿһÖÖ¼ÆËãÊýÄ¿µÄ½á¹û£¬ÑÓ³Ù£¨delay bias£©·Ö±ðÊÇ 10 ms¡¢30 ms¡¢90 ms¡¢270 ms,¡¢810 ms ºÍ 2430 ms£¬µ«ÊÇÔÚ¸Ãͼ±íÖУ¬ÎÒ½ö°üÀ¨ÁË 10 ms ºÍ 2430 ms µÄ½á¹û£¬ÕâÑùËùÓеÄÊý×Ö¶¼±»¼ò»¯£¬¶øÇÒ¸üÈÝÒ×Àí½â¡£
ÎÒÐèÒª½âÊÍ "delay bias." µÄº¬Ò壬Èç¹ûÒ»¸ö²âÊÔÔËÐÐµÄ delay bias ÊÇ n£¬Ôòÿһ¸ö¼ÆË㶼ÓÐÒ»¸ö±¶Êý n ×÷ΪÆä¼ÆËãʱ¼ä¡£ÀýÈ磬Èç¹ûÊÔÑéµÄÊÇ delay bias Ϊ 10 µÄ 5 ¸ö¼ÆË㣬ÔòÆäÖÐÒ»¸ö¼ÆË㽫ִÐÐ 50 ms£¬µÚ¶þ¸ö½«Ö´ÐÐ 40 ms£¬µÚÈý¸ö½«Ö´ÐÐ 30 ms£¬µÚËĸö½«Ö´ÐÐ 20 ms£¬¶øµÚÎå¸ö½«Ö´ÐÐ 10 ms¡£²¢ÇÒ£¬µ±ÕâЩ¼ÆËã±»´®ÐÐÖ´ÐÐʱ£¬¼Ù¶¨Îª×îÔãµÄÇé¿ö£¬ËùÒÔ¾ßÓÐ×ÑӳٵļÆËãÊ×Ïȱ»Ö´ÐУ¬ÆäËûµÄ¼ÆËã°´½µÐòÅÅÁÐÆäºó¡£ÓÚÊÇ£¬ÔÚ"ÀíÏë"Çé¿öÏ£¨¾ÍÊÇ˵£¬¼ÆËãÖ®¼äûÓÐÖصþ£©£¬¶ÔÓÚ»ùÓÚCPUµÄ¼ÆËãÀ´Ëµ£¬È«²¿ËùÐèµÄʱ¼ä½«ÊÇ 50 m! s + 40 ms + 30 ms + 20 ms + 10 ms = 150 ms¡£
¶ÔÓÚÏûºÄʱ! ¼äͼ±íÀ´ ˵£¬ y ÖáµÄÖµÓëºÁÃë¶ÔÓ¦£¬¶ÔÓÚÏìӦʱ¼äͼ±íÀ´Ëµ£¬y ÖáµÄÖµÓëÏà¶Ô£¨relative turnaround£©³¤¶È£¨¼´£¬Êµ¼ÊÖ´ÐÐËù»¨·ÑµÄºÁÃëÊý³ýÒÔÔ¤ÆڵĺÁÃëÊý£©Ïà¶ÔÓ¦¡£
»ùÓÚ I/O µÄÈÎÎñ
ÒÔÏûºÄʱ¼äºÍ turnaround ʱ¼äÀ´ºâÁ¿£¬»ùÓÚ I/O µÄÏ̵߳±²¢·¢Ö´ÐÐʱ±È´®ÐÐÖ´ÐÐÒªºÃµÃ¶à¡£×÷Ϊ¼ÆËãµÃÒ»¸ö¹¦ÄÜ£¬¶ÔÓÚ²¢·¢Ö´ÐÐÀ´Ëµ£¬ÏûºÄʱ¼äÒÔÏßÐÔģʽµÝÔö£¬¶ø¶ÔÓÚ´®ÐÐÖ´ÐÐÀ´Ëµ£¬ÔòÒÔÖ¸ÊýģʽµÝÔö£¨ÓÐ¹Ø Windows NT Çë²ÎÔÄͼ 1 ºÍ 2£¬ÓÐ¹Ø Windows 95 Çë²ÎÔÄͼ 5 ºÍ 6£©¡£
Çë×¢Ò⣬Õâ¸ö½áÂÛÓëÎÒÃÇÇ°Ãæ¶Ô»ùÓÚ I/O µÄ¼ÆËãµÄ·ÖÎöÊÇÒ»Öµģ¬»ùÓÚ I/O µÄ¼ÆËãÊǶàÏ̵߳ÄÓÅÐãºòÑ¡? Ë£¬ÒòΪһ¸öÏß³ÌÔڵȴ?I/O ÇëÇó½áÊøʱ±»¹ÒÆ𣬶øÕâ¶Îʱ¼ä¸ÃÏ̲߳»»áÕ¼Óà CPU ʱ¼ä£¬ÓÚÊÇ£¬Õâ¶Îʱ¼ä¾Í¿ÉÒÔ±»ÆäËûµÄÏß³ÌËùʹÓá£
¶ÔÓÚ²¢·¢¼ÆËãÀ´Ëµ£¬Æ½¾ùÏìӦʱ¼äÊÇÒ»¸ö³£Êý£¬¶ÔÓÚ´®ÐмÆËãÀ´Ëµ£¬Æ½¾ùÏìӦʱ¼äÔòÏßÐÔµÝÔö£¨Çë·Ö±ð²ÎÔÄͼ 3¡¢4¡¢7 ºÍ 8£©¡£
Çë×¢ÒâÎÞÂÛÈκÎÇé¿ö£¬Ö»ÓÐÉÙÊý¼¸¸ö¼ÆËãÖ´Ðеķ½°¸ÖУ¬ÎÞÂÛ´®Ðлò²¢·¢µÄÖ´ÐУ¬ÎÞÂÛ²âÊÔ²ÎÊýÈçºÎÉèÖ㬲¢Ã»ÓÐʲôÃ÷ÏÔµÄÇø±ð¡£
»ùÓÚ CPU µÄÈÎÎñ
ÕýÈçÎÒÃÇÇ°ÃæËùÌáµ½µÄ£¬ÔÚÒ»¸öµ¥´¦ÀíÆ÷µÄ¼ÆËã»úÖУ¬»ùÓÚ CPU µÄÈÎÎñµÄ²¢·¢Ö´ÐÐËٶȲ»¿ÉÄܱȴ®ÐÐÖ´ÐÐËٶȿ죬µ«ÊÇÎÒÃÇ¿ÉÒÔ¿´µ½£¬ÔÚ Windows NT ÏÂÏ̴߳´½¨ºÍÇл»µÄ¶îÍ⿪Ïú·Ç³£Ð¡£»¶ÔÓڷdz£¶ÌµÄ¼ÆË㣬²¢·¢Ö´Ðнö½ö±È´®ÐÐÖ´ÐÐÂý 10%£¬¶øËæ׿ÆË㳤¶ÈµÄÔö¼Ó£¬ÕâÁ½¸öʱ¼ä¾Í·Ç³£½Ó½üÁË¡£ÒÔÏìӦʱ¼äÀ´ºâÁ¿£¬ÎÒÃÇ¿ÉÒÔ·¢ÏÖ¶ÔÓÚ³¤¼ÆË㣬²¢·¢Ö´ÐÐÏà¶ÔÓÚ´®ÐÐÖ´ÐеÄÏìÓ¦ÔöÒæ¿ÉÒÔ´ïµ½ 50%£¬µ«ÊǶÔÓڶ̵ļÆË㣬´®ÐÐÖ´ÐÐʵ¼ÊÉϱȲ¢·¢Ö´Ðиü¼ÓºÃ¡£
Windows 95 ºÍ Windows NT Ö®¼äµÄ±È½Ï
Èç¹ûÎÒÃÇ¿´Ò»¿´Óйس¤¼ÆËãµÄͼ±í£¨¼´£¬Í¼2¡¢4¡¢6 ºÍ 8£©£¬ÎÒÃÇ¿ÉÒÔ·¢ÏÖÔÚ Windows 95 ºÍ Windows NT ÏÂÆäÐÐΪÊǼ«ÆäÀàËƵġ£Çë²»Òª±»ÕâÑùµÄÊÂʵËùÃÔ»ó£¬? ´ºÃÏ?Windows 95 ´¦Àí»ùÓÚI/OµÄ¼ÆËãÓë»ùÓÚCPUµÄ¼ÆË㲻ͬÓÚ Window! s NT¡£ÎÒ °ÑÕâÒ»½á¹ûµÄÔÒò¹é½áΪÕâÑùÒ»¸öÊÂʵ£¬ÄǾÍÊÇÎÒÓÃÀ´¾ö¶¨¶àÉÙ¸ö²âÊÔÑ»·Óë 1 ºÁÃëÏà¶ÔÓ¦µÄËã·¨£¨ÈçÇ°ÃæËùÊö£©ÊǷdz£²»¾«È·µÄ£»ÎÒ·¢ÏÖͬÑùÊÇÕâ¸öËã·¨£¬ÔÚÍêÈ«ÏàͬµÄ»·¾³ÏÂÖ´Ðжà´Îʱ£¬Ëù²úÉúµÄ½á¹ûÖ®¼äµÄ²îÒì×î´óʱ¿É´ï20%¡£ËùÒÔ£¬±È½Ï»ùÓÚ CPU µÄ¼ÆËãºÍ»ùÓÚ I/O µÄ¼ÆËãʵ¼ÊÉÏÊDz»¹«Æ½µÄ¡£
Windows 95 ºÍ Windows NT Ö®¼ä²»Í¬µÄÒ»µãÊǵ±Õë¶Ô¶ÌµÄ¼ÆËãʱ¡£ÈçÎÒÃÇ´Óͼ1 ºÍ5 Ëù¿´µ½µÄ£¬¶ÔÓÚ²¢·¢µÄ»ùÓÚI/OµÄ¶Ì¼ÆË㣬Windows NT µÄЧ¹ûÒªºÃµÃ¶à¡£ÎÒ°ÑÕâÒ»½á¹ûµÃÔÒò¹é½áΪ¸ü¼ÓÓÐЧÂʵÃÏ̴߳´½¨·½°¸¡£Çë×¢Ò⣬¶ÔÓÚ³¤µÃ¼ÆË㣬´®ÐÐÓë²¢·¢I/O²Ù×÷Ö®¼äµÄ²î±ðÏûʧÁË£¬ËùÒÔÕâÀïÎÒÃÇ´¦ÀíµÄÊǹ̶¨µÄ¡¢Ïà¶Ô±È½ÏСµÄ¶îÍ⿪Ïú¡£
¶ÔÓڶ̵ļÆË㣬ÒÔÏìӦʱ¼äÀ´ºâÁ¿£¨Èçͼ 3 ºÍ 7£©£¬Çë×¢Ò⣬ÔÚ Windows NT Ï£¬ÔÚ10¸öÏ̴߳¦ÓÐÒ»¸ö¶Ïµã£¬ÔÚÕâÀï¸ü¶àµÄ¼ÆËã²¢·¢Ö´ÐÐÓиüºÃµÄЧ¹û£¬¶ø¶ÔÓÚ Windows 95 £¬ÔòÊÇ´®ÐмÆËãÓиüºÃµÄÈÝÁ¿¡£
Çë×¢ÒâÕâЩ±È½Ï¶¼ÊÇ»ùÓÚµ±Ç°°æ±¾µÄ²Ù×÷ϵͳµÃµ½µÄ£¨Windows NT 3.51 °æºÍ Windows 95£©£¬Èç¹û¿¼Âǵ½²Ù×÷ϵͳµÄÎÊÌ⣬ÄÇôÏß³ÌÒýÇæ·Ç³£ÓпÉÄܱ»ÔöÇ¿£¬ËùÒÔÁ½¸ö²Ù×÷ϵͳ֮¼äµÄ¸÷×ÔÐÐΪµÄ²îÒìÓпÉÄÜÏûʧ¡£µ«ÊÇ£¬ÓÐÒ»µãºÜÓÐȤµÄҪעÒ⣬¶Ì¼ÆËã? »°ã²»±ØҪʹÓöàỊ̈߳¬ÓÈÆäÊÇÔ?Windows 95 Ï¡£
½¨Òé
ÕâЩ½á¹û¿ÉÒÔÍƳöÏÂÃæµÄ½¨Ò飺¾ö¶¨¶àÏß³ÌÐÔÄܵÄ×îÖ÷ÒªÒòËØÊÇ»ùÓÚ I/O µÄ¼ÆËãºÍ»ùÓÚ CPU µÄ¼ÆËãµÄ±ÈÀý£¬¾ö¶¨ÊÇ·ñ²ÉÓöàÏ̵߳ÄÖ÷ÒªÌõ¼þÊÇǰ̨µÄÓû§ÏìÓ¦¡£
ÈÃÎÒÃǼٶ¨ÔÚÄúµÄÓ¦ÓóÌÐòÖУ¬Óжà¸ö×Ó¼ÆËã¿ÉÒÔÔÚ²»Í¬µÄÏß³ÌÖÐDZÔڵر»Ö´ÐС£ÎªÁ˾ö¶¨¶ÔÕâЩ¼ÆËãʹÓöàÏß³ÌÊÇ·ñÓÐÒâÒ壬Ҫ¿¼ÂÇÏÂÃæµÄ¼¸µã¡£
Èç¹ûÓû§½çÃæÏìÓ¦·ÖÎö¾ö¶¨Ä³Ð©ÊÂÇéÓ¦¸ÃÔÚµÚ¶þÏß³ÌÖÐʵÏÖ£¬ÄÇô£¬¾ö¶¨½«ÒªÖ´ÐеÄÈÎÎñÊÇ»ùÓÚI/OµÄ¼ÆË㻹ÊÇ»ùÓÚCPU µÄ¼ÆËã¾ÍºÜÓÐÒâÒå¡£»ùÓÚI/OµÄ¼ÆËã×îºÃ±»ÖØж¨Î»µ½ºǫ́Ïß³ÌÖС££¨µ«ÊÇ£¬Çë×¢Ò⣬Òì²½µ¥Ïß³ÌµÄ I/O ´¦Àí¿ÉÄܱȶàÏß³Ìͬ²½I/OÒªºÃ£¬ÕâÒª¿´ÎÊÌâ¶ø¶¨£©·Ç³£³¤µÄ»ùÓÚCPUµÄÏ߳̿ÉÄÜ´ÓÔÚ²»Í¬µÄÏß³ÌÖб»Ö´ÐлñÒ棻µ«ÊÇ£¬³ý·Ç¸ÃÏ̵߳ÄÏìÓ¦·Ç³£ÖØÒª£¬·ñÔò£¬ÔÚͬһ¸öºǫ́Ïß³ÌÖÐÖ´ÐÐËùÓеĻùÓÚ CPU µÄÈÎÎñ¿ÉÄܱÈÔÚ²»Í¬µÄÏß³ÌÖÐÖ´ÐÐËü¸üÓÐÒâÒå¡£Çë¼ÇסÔÚÈκεÄÇé¿öÏ£¬¶Ì¼ÆËãÔÚ²¢·¢Ö´ÐÐʱһ°ã»áÔÚÏ̴߳´½¨Ê±Óзdz£´óµÄ¶îÍ⿪Ïú¡£
Èç¹û¶ÔÓÚ»ùÓÚCPUµÄ¼ÆËã - ¼´Ã¿Ò»¸ö¼ÆËãµÄ½á¹ûÖ»ÒªµÃµ½Á˾ÍÁ¢¿ÌÄÜÓ¦ÓõļÆË㣬ÏìÓ¦ÊÇ×î¹Ø¼üµÄ£¬ÄÇô£¬ÄúÓ¦¸Ã³¢ÊÔ¾ö¶¨ÕâЩ¼ÆËãÊÇ·ñÄܹ»ÒÔÉýÐòÅÅÐò£¬? Ú´ËÖÖÇé¿öÏÂÕâЩ¼ÆËã´®ÐÐÖ´ÐеÄÕûÌåÐÔÄÜÈÔÈ»»á±È²¢ÐÐÖ´ÐÐÒªºÃ¡£Çë×! ¢Ò⣬ÓÐÒ »Ð©¼ÆËã»úµÄÌåϵ½á¹¹µÄÉè¼ÆÊÇΪÁËÄܹ»·Ç³£ÓÐЧÂʵش¦Àí³¤µÄ¼ÆË㣨ÀýÈç¾ØÕó²Ù×÷£©£¬ÄÇô£¬ÔÚÕâÑùµÄ¼ÆËã»úÉ϶Գ¤µÄ¼ÆËãʵÐжàÏ̻߳¯µÄ»°£¬Äú¿ÉÄÜʵ¼ÊÉÏÎþÉüÁËÕâÖֽṹµÄÓÅÊÆ¡?br> ËùÓеÄÕâЩ·ÖÎö¶¼¼Ù¶¨¸ÃÓ¦ÓóÌÐòÊÇÔËÐÐÔÚÒ»¸öµ¥´¦ÀíÆ÷µÄ¼ÆËã»úÉÏ£¬²¢ÇÒ¼ÆËãÖ®¼äÊÇÏ໥¶ÀÁ¢µÄ¡£Êµ¼ÊÉÏ£¬Èç¹û¼ÆËãÖ®¼äÏ໥ÒÀÀµ¶øÐèÒª´®ÐÐÉè¼Æ£¬´®ÐÐÖ´ÐеÄÐÔÄܽ«²»ÊÜÓ°Ï죨ÒòΪ´®ÐÐÊÇÒþʽµÄ£©£¬¶ø²¢·¢Ö´Ðеİ汾½«×ÜÊÇÊܵ½²»ÀûµÄÓ°Ïì¡£
ÎÒ»¹½¨ÒéÄú»ùÓÚ¼ÆËãÖ®¼äÏ໥ÒÀÀµµÄ³Ì¶È¾ö¶¨¶àÏ̵߳ÄÉè¼Æ¡£ÔÚ´ó¶àÊýÇé¿öÏÂ×Ó¼ÆËãÏ̻߳¯²»ÓÃ˵ÊǺõģ¬µ«ÊÇ£¬Èç¹û¶ÔÓÚ²ð·ÖÄúµÄÓ¦ÓóÌÐòΪ¶à¸ö¿ÉÒÔÔÚ²»Í¬Ï̴߳¦ÀíµÄ×Ó¼ÆËãµÄ·½·¨ÓжàÖÖÑ¡Ôñ£¬ÎÒÍƼöÄúʹÓÃͬ²½µÄ¸´ÔÓÐÔ×÷Ϊһ¸öÌõ¼þ¡£»»¾ä»°Ëµ£¬Èç¹û²ð·Ö³É¶à¸öÏ̶߳øÐèÒª·Ç³£Éٺͷdz£Ö±½ÓµÄͬ²½£¬ÄÇôÕâÖÖ·½°¸¾Í±ÈÐèҪʹÓôóÁ¿ÇÒ¸´ÔÓµÄÏß³Ìͬ²½µÄ·½°¸ÒªºÃ¡£
×îºóÒ»¸öÇë×¢ÒâÊÇ£¬ÇëÀμÇÏß³ÌÊÇÒ»ÖÖϵͳ×ÊÔ´£¬²»ÊÇÎÞ´ú¼ÛµÄ£»ËùÒÔ£¬there may be a greater penalty to multithreading than performance hits alone. ×÷ΪµÚÒ»¹æÔò£¨rule of thumb£©£¬ÎÒ½¨ÒéÄúÔÚʹÓöàÏß³ÌʱҪ±£³ÖÀíÖDz¢ÇÒ½÷É÷¡£ÔÚ¶àÏß³ÌȷʵÄܹ»¸øÄúµÄÓ¦ÓóÌÐòÉè¼Æ´øÀ´ºÃ´¦µÄʱ? ò²ÅʹÓÃËüÃÇ£¬µ«ÊÇ£¬Èç¹û´®ÐмÆËã¿ÉÒԴﵽͬÑùµÄЧ¹û£¬¾Í²»ÒªÊ¹ÓÃËüÃÇ¡?br> ×ܽá
ÔËÐи½¼ÓµÄÐÔÄܲâÊÔÌ×¼þ²úÉúÁËһЩÌØÊâµÄ½á¹û£¬ÕâЩ½á¹ûÌṩÁËÐí¶àÓйز¢·¢Ó¦ÓóÌÐòÉè¼ÆµÄÄÚ²¿Âß¼¡£Çë×¢ÒâÎÒµÄÐí¶à¼Ù¶¨ÊǷdz£»ù±¾µÄ£»ÎÒÑ¡ÔñÁ˱ȽϷdz£³¤µÄ¼ÆËãºÍ·Ç³£¶ÌµÄ¼ÆË㣬ÎÒ¼Ù¶¨¼ÆËãÖ®¼äÍêÈ«¶ÀÁ¢£¬ÒªÃ´ÍêÈ«ÊÇ»ùÓÚI/OµÄ¼ÆË㣬ҪôÊÇÍêÈ«»ùÓÚCPUµÄ¼ÆËã¡£¶ø¾ø´ó¶àÊýµÄÏÖʵÎÊÌ⣬Èç¹ûÒÔ¼ÆË㳤¶ÈºÍ boundedness À´ºâÁ¿£¬¶¼ÊǽéÓÚÕâÁ½ÖÖÇé¿öÖ®¼äµÄ¡£Çë°Ñ±¾ÎÄÖеIJÄÁϽö½ö×÷Ϊһ¸öÆðµã£¬ËüʹÄú¸ü¼ÓÏêϸµØ·ÖÎöÄúµÄÓ¦ÓóÌÐò£¬ÒÔ¾ö¶¨ÊÇ·ñʹÓöàÏ̡߳£
ÔÚ±¾ÏµÁеĽ«À´µÄһƪÎÄÕÂÖУ¬ÎÒ½«ÌÖÂÛͨ¹ýÒì²½I/OÀ´ÔöÇ¿»ùÓÚI/OµÄ²Ù×÷µÄÐÔÄÜ¡£ |