• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            數據加載中……

            I/O Completion Ports-I/O完成端口

            I/O completion ports are the mechanism by which an application uses a pool of threads that was created when the application was started to process asynchronous I/O requests. These threads are created for the sole purpose of processing I/O requests. Applications that process many concurrent asynchronous I/O requests can do so more quickly and efficiently by using I/O completion ports than by using creating threads at the time of the I/O request.

            I/O完成端口是一種機制,通過這個機制,應用程序在啟動時會首先創建一個線程池,然后該應用程序使用線程池處理異步I/O請求。這些線程被創建的唯一目的就是用于處理I/O請求。對于處理大量并發異步I/O請求的應用程序,相比在I/O請求發生時才創建線程來說,使用完成端口(s)可以做的更快且更有效率。

            The CreateIoCompletionPort function associates an I/O completion port with one or more file handles. When an asynchronous I/O operation started on a file handle associated with a completion port is completed, an I/O completion packet is queued to the port. This can be used to combine the synchronization point for multiple file handles into a single object. 

            CreateIoCompletionPort函數使一個I/O完成端口與一個或更多的文件句柄發生關聯。當在與一個完成端口相關的文件句柄上啟動的異步I/O操作完成時,一個I/O完成包就會進入到該完成端口的隊列中。對于多個文件句柄來說,這種機制可以用來把多文件句柄的同步點放在單個對象中。(言下之意,如果我們需要對每個句柄文件進行同步,一般而言我們需要多個對象(如:Event來同步),而我們使用IO Complete Port 來實現異步操作,我們可以同多個文件相關聯,每當一個文件中的異步操作完成,就會把一個complete package放到隊列中,這樣我們就可以使用這個來完成所有文件句柄的同步)
            A thread uses the GetQueuedCompletionStatus function to wait for a completion packet to be queued to the completion port, rather than waiting directly for the asynchronous I/O to complete. Threads that block their execution on a completion port are released in last-in-first-out (LIFO) order. This means that when a completion packet is queued to the completion port, the system releases the last thread to block its execution on the port. 

            調用GetQueuedCompletionStatus函數,某個線程就會等待一個完成包進入到完成端口的隊列中,而不是直接等待異步I/O請求完成。線程(們)就會阻塞于它們的運行在完成端口(按照后進先出隊列順序的被釋放)。這就意味著當一個完成包進入到完成端口的隊列中時,系統會釋放最近被阻塞在該完成端口的線程。
            When a thread calls GetQueuedCompletionStatus, it is associated with the specified completion port until it exits, specifies a different completion port, or frees the completion port. A thread can be associated with at most one completion port.
            調用GetQueuedCompletionStatus,線程就會將會與某個指定的完成端口建立聯系,一直延續其該線程退出,或被指定了不同的完成端口,或者釋放了與完成端口的聯系。一個線程只能與最多不超過一個的完成端口發生聯系。
            The most important property of a completion port is the concurrency value. The concurrency value of a completion port is specified when the completion port is created. This value limits the number of runnable threads associated with the completion port. When the total number of runnable threads associated with the completion port reaches the concurrency value, the system blocks the execution of any subsequent threads that specify the completion port until the number of runnable threads associated with the completion port drops below the concurrency value.

            完成端口最重要的特性就是并發量。完成端口的并發量可以在創建該完成端口時被指定。該并發量限制了與該完成端口相關聯的可運行線程的數目。當與該完成端口相關聯的可運行線程的總數目達到了該并發量,系統就會阻塞任何與該完成端口相關聯的后續線程的執行,直到與該完成端口相關聯的可運行線程數目下降到小于該并發量為止。

            The most efficient scenario occurs when there are completion packets waiting in the queue, but no waits can be satisfied because the port has reached its concurrency limit. In this case, when a running thread calls GetQueuedCompletionStatus, it will immediately pick up the queued completion packet. No context switches will occur, because the running thread is continually picking up completion packets and the other threads are unable to run. 

            最有效的假想是發生在有完成包在隊列中等待,而沒有等待被滿足,因為此時完成端口達到了其并發量的極限。此時,一個正在運行中的線程調用GetQueuedCompletionStatus時,它就會立刻從隊列中取走該完成包。這樣就不存在著環境的切換,因為該處于運行中的線程就會連續不斷地從隊列中取走完成包,而其他的線程就不能運行了。
            The best value to pick for the concurrency value is the number of CPUs on the machine. If your transaction required a lengthy computation, a larger concurrency value will allow more threads to run. Each transaction will take longer to complete, but more transactions will be processed at the same time. It is easy to experiment with the concurrency value to achieve the best effect for your application. 

            對于并發量最好的選值就是您計算機中CPU的數目。如果您的事務處理需要一個漫長的計算時間,一個比較大的并發量可以允許更多線程來運行。雖然完成每個事務處理需要花費更長的時間,但更多的事務可以同時被處理。對于應用程序來說,很容易通過測試并發量來獲得最好的效果。
            The PostQueuedCompletionStatus function allows an application to queue its own special-purpose I/O completion packets to the completion port without starting an asynchronous I/O operation. This is useful for notifying worker threads of external events.

            PostQueuedCompletionStatus函數允許應用程序可以針對自定義的專用I/O完成包進行排隊,而無需啟動一個異步I/O操作。這點對于通知外部事件的工作者線程來說很有用。

            The completion port is freed when there are no more references to it. The completion port handle and every file handle associated with the completion port reference the completion port. All the handles must be closed to free the completion port. To close the port handle, call the CloseHandle function.
            在沒有更多的引用針對某個完成端口時,需要釋放該完成端口。該完成端口句柄以及與該完成端口相關聯的所有文件句柄都需要被釋放。調用CloseHandle可以釋放完成端口的句柄。

            本文來自CSDN博客,http://blog.csdn.net/vieri_ch/archive/2006/10/12/1332054.aspx

            posted on 2010-08-30 09:17 Stone xin 閱讀(341) 評論(0)  編輯 收藏 引用

            成人a毛片久久免费播放| 久久久久久曰本AV免费免费| 狠狠色婷婷久久综合频道日韩 | 丁香久久婷婷国产午夜视频| 国内精品久久久久久久影视麻豆 | 亚洲国产成人久久综合一| 久久精品成人影院| 久久精品国产免费观看| 欧美综合天天夜夜久久| 伊色综合久久之综合久久| 精品国产乱码久久久久久郑州公司 | 久久免费香蕉视频| 久久亚洲精品成人av无码网站| 欧美精品一区二区精品久久| 国产A三级久久精品| 久久伊人影视| 久久精品国产精品国产精品污| 99久久这里只精品国产免费| 久久精品国产秦先生| 中文字幕无码久久人妻| 国产日韩久久久精品影院首页| 欧美熟妇另类久久久久久不卡| 久久婷婷五月综合色99啪ak| 久久精品国产69国产精品亚洲| 伊人久久大香线蕉av不卡| 天天影视色香欲综合久久| 99久久精品国产一区二区| 97久久精品人妻人人搡人人玩| 波多野结衣久久| 中文字幕无码久久人妻| 亚洲AⅤ优女AV综合久久久| 久久91这里精品国产2020| 亚洲嫩草影院久久精品| 麻豆精品久久精品色综合| 久久不射电影网| 久久久久久久尹人综合网亚洲| av无码久久久久久不卡网站| 久久99精品久久只有精品| 69久久夜色精品国产69| 狠色狠色狠狠色综合久久| 日本道色综合久久影院|