Simplified background:
My app runs a lot of tasks. Most of them are CPU intensive.
One task (which is actually a single thread running in a loop, listening to packets from the network), is very much a "realtime" task. To make it more interesting, that thread is native code called using pinvoke
.
The problem:
When a lot of traffic is showing, the tasks are working very hard, and all the cores are maxing out. When that happens, the "realtime" thread (which runs on a 100% cpu core), starts to drop packets, because it doesn't get enough cpu time.
The question:
It is possible to somehow "reserve" one core for the "realtime" thread, and limit all the other threads (tasks) to other cores?
- Of course, there are other processes running, consuming CPU time as well, but let's assume they consume little and constant resources.
- This is a real problem that can be solved by "throw more cpu on it"... Not an option...
EDIT - Answering many useful comments:
- We use WinPcap to capture all packets, which can be many (many).
- The "realtime" thread is not really "realtime" (I think "realtime" is for processes - In .net ThreadPriority uses "Normal", "AboveNormal", etc..)
- The "realtime" thread calls WinPcap serially, packet after packet. We suspect that since it is starved enough, it doesn't keep up, and WinPcap's buffer is overflowed.