ããåæ¥I/Oæä½
ããæ§è¡æ¥éª¤
ãã1. ç¨åºéè¿FileStream对象æ¥æå¼ç£çæ件ï¼ç¶åè°ç¨Readæ¹æ³ï¼å
é¨è°ç¨Win32 ReadFileå½æ°ï¼ï¼ä»æ件ä¸è¯»åæ°æ®ãè¿æ¶ï¼çº¿ç¨ä»æ管代ç 转å为æ¬æº/ç¨æ·æ¨¡å¼ä»£ç ã
ãã2. Win32 ReadFileå½æ°çæä¸ä¸ªI/O请æ±å
ï¼IRPï¼ï¼å¹¶ä¼ éç»Windowså
æ ¸ã
ãã3. Windowså
æ ¸å°IRPä¼ éç»I/O硬件设å¤é©±å¨ç¨åºçIRPéåã
ãã4. 硬件设å¤æ§è¡I/Oæä½ãå¨æ¤æé´ï¼ååºI/O请æ±ç线ç¨å°åæç¡ç ç¶æãè¿æ ·å¯ä»¥é¿å
浪费CPUæ¶é´ï¼ä½ä¾ç¶ä¼æµªè´¹å
å空é´ãå 为线ç¨çç¨æ·æ¨¡å¼æ ãå
æ ¸æ¨¡å¼æ ã线ç¨ç¯å¢ååå
¶ä»æ°æ®ç»æä»å¨å
åä¸ï¼èä¸æ 人访é®ã
ãã5. å¨ç¡¬ä»¶è®¾å¤å®æI/Oæä½åï¼çº¿ç¨è¢«å¤éï¼ä»å
æ ¸æ¨¡å¼è¿åç¨æ·æ¨¡å¼ï¼åè¿åæ管代ç ã
ããæ§è½åæ
ãã1. å½å®¢æ·ç«¯åèµ·ä¸ä¸ªI/O请æ±æ¶ï¼çº¿ç¨æ± ä¼å建ä¸ä¸ªçº¿ç¨ï¼åèµ·I/O请æ±åï¼çº¿ç¨ä¼é»å¡å¹¶çå¾
ååºãå½å®¢æ·ç«¯æå¤ä¸ªI/O请æ±æ¶ï¼çº¿ç¨æ± ä¸å¾ä¸å建å¤ä¸ªçº¿ç¨ï¼è¿äºçº¿ç¨é½ä¼é»å¡ã
ãã2. å½I/Oååºè¯·æ±æ¶ï¼å¤ä¸ªçº¿ç¨è¢«è§£éï¼å¼å§æ§è¡ãè¿æ¶ï¼ç±äºCPUå
æ ¸æ°ééå¶ï¼CPU被迫æ§è¡é¢ç¹çä¸ä¸æåæ¢ï¼è¿è¿ä¸æ¥æ害äºæ§è½ã
ããå¼æ¥I/Oæä½
ããæ¦è¿°
ããå¼æ¥æ§è¡çI/Oéå¶çæä½ï¼å
许å°ä»»å¡äº¤ç±ç¡¬ä»¶è®¾å¤å¤çï¼æé´ä¸å ç¨çº¿ç¨åCPUèµæºã
ããåç§I/Oæä½çç»æç±çº¿ç¨æ± æ¥å¤çï¼å æ¤çº¿ç¨æ± ä»ç¶æ®æ¼éè¦çè§è²ã
ããæ§è¡æ¥éª¤
ãã1. ç¨åºéè¿FileStream对象æ¥æå¼ç£çæ件ï¼ç¶åè°ç¨ReadAsyncæ¹æ³ï¼å
é¨è°ç¨Win32 ReadFileå½æ°ï¼ï¼ä»æ件ä¸è¯»åæ°æ®ãè¿æ¶ï¼çº¿ç¨ä»æ管代ç 转å为æ¬æº/ç¨æ·æ¨¡å¼ä»£ç ã
ãã2. Win32 ReadFileå½æ°çæä¸ä¸ªI/O请æ±å
ï¼IRPï¼ï¼å¹¶ä¼ éç»Windowså
æ ¸ã
ãã3. Windowså
æ ¸å°IRPä¼ éç»I/O硬件设å¤é©±å¨ç¨åºçIRPéåã
ãã4. 线ç¨ç«å³ä»å
æ ¸æ¨¡å¼è¿åç¨æ·æ¨¡å¼ï¼åè¿åæ管代ç ãè¿æ¶FileStreamçReadAsyncæ¹æ³è¿åä¸ä¸ªTask<Int32>对象ã
ãã5. 硬件设å¤æ§è¡I/Oæä½ã
ãã6. å¨ç¡¬ä»¶è®¾å¤å®æI/Oæä½åï¼å°å®æçIRPæ¾å°çº¿ç¨æ± éåä¸ã
ãã7. å°æ¥æ个æ¶é´ï¼ä¸ä¸ªçº¿ç¨æ± 线ç¨ä¼æåå®æçIRPï¼å¹¶è®¿é®è¯»åå°çæ°æ®ã
ããæ§è½åæ
ãã1. å¨ç¡¬ä»¶è®¾å¤æ§è¡I/Oæä½æé´ï¼çº¿ç¨ä¸é»å¡ï¼å¯ä»¥é¿å
线ç¨æ± å建æ´å¤ç线ç¨ã
ãã2. 硬件设å¤æ§è¡I/Oæä½åï¼å®çååºä¹ä¼è¿å
¥çº¿ç¨æ± éåï¼ç±çº¿ç¨æ± åé
线ç¨è¿è¡å¤çï¼å¯ä»¥æ´åçå°å©ç¨çº¿ç¨ï¼é¿å
CPUçé¢ç¹ä¸ä¸æåæ¢ã
ãã3. å¼æ¥I/Oå°çº¿ç¨æ§å¶å¨å°æ°å 个ï¼å¯ä»¥èçå
å空é´
温馨提示:答案为网友推荐,仅供参考