Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between a worker thread and an I/O thread?

Looking at the processmodel element in the Web.Config there are two attributes.

maxWorkerThreads="25"  maxIoThreads="25" 

What is the difference between worker threads and I/O threads?

like image 564
John Avatar asked Sep 26 '08 02:09

John


People also ask

What is an IO thread?

The IO thread option allows each disk image to have its own thread instead of waiting in a queue with everything else.

What is meant by worker thread?

Worker thread is a continuous parallel thread that runs and accepts messages until the time it is explicitly closed or terminated. Messages to a worker thread can be sent from the parent thread or its child worker threads. Through out this document, parent thread is referred as thread where a worker thread is spawned.

What is worker thread and main thread?

People use the word "worker" when they mean a thread that does not own or interact with UI. Threads that do handle UI are called "UI" threads. Usually, your main (primary) thread will be the thread that owns and manages UI. And then you start one or more worker threads that do specific tasks.

What are IO threads in Java?

I/O thread is started at the line marked as "1". The main thread falls to sleep and waits for the I/O thread to complete. After it's done, it sends the data back to the main thread. Then the main thread wakes up and continues working.


1 Answers

Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data.

I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods of time (hundreds of milliseconds). They also can be optimized and used differently to take advantage of I/O completion port functionality in the Windows kernel. A single I/O thread may be managing multiple completion ports to maintain throughput.

Windows has a lot of capabilities for dealing with I/O blocking whereas ASP.NET/.NET has a plain concept of "Thread". ASP.NET can optimize for I/O by using more of the unmanaged threading capabilities in the OS. You wouldn't want to do this all the time for every thread as you lose a lot of capabilities that .NET gives you which is why there is a distinction between how the threads are intended to be used.

Worker threads are threads upon which regular "work" or just plain code/processing happens. Worker threads are unlikely to block a lot or wait on anything and will be short running and therefore require more aggressive scheduling to maximize processing power and throughput.

[Edit]: I also found this link which is particularly relevant to this question: http://blogs.msdn.com/ericeil/archive/2008/06/20/windows-i-o-threads-vs-managed-i-o-threads.aspx

like image 172
chadmyers Avatar answered Oct 05 '22 21:10

chadmyers