开发者

Number of Concurrent Threads in CreateIoCompletionPort

开发者 https://www.devze.com 2023-03-27 08:58 出处:网络
On MSDN page for CreateIoCompletionPort there\'s a very short description for the last parameter of this function:

On MSDN page for CreateIoCompletionPort there's a very short description for the last parameter of this function:

NumberOfConcurrentThreads [in]

The maximum number of threads that the op开发者_运维技巧erating system can allow to concurrently process I/O completion packets for the I/O completion port...

What exactly does it mean? I'm confused with the word 'concurrently' - this sounds like different threads process the same I/O packet? And also, what happens if I call GetQueuedCompletionStatus from more threads than allowed?


See http://msdn.microsoft.com/en-us/library/aa365198(v=VS.85).aspx

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 associated with that completion port until the number of runnable threads drops below the concurrency value.

Where "concurrency value" is NumberOfConcurrentThreads. (And there's lots more good stuff.)

Unless you're doing something a bit unusual, 0 seems to be a good value to pass, where the concurrency value is the number of cores. Then you can have every core pulling completion results off the queue without ever blocking or context switching, assuming there is enough work available.

Any extra threads that make calls to GetQueuedCompletionStatus will block, even if there are completions available.

0

精彩评论

暂无评论...
验证码 换一张
取 消