c++ - Is it possible to run code on a "reserved" cpu core? -


simplified background:

my app runs lot of tasks. of them cpu intensive.
1 task (which single thread running in loop, listening packets network), "realtime" task. make more interesting, thread native code called using pinvoke.

the problem:

when lot of traffic showing, tasks working hard, , cores maxing out. when happens, "realtime" thread (which runs on 100% cpu core), starts drop packets, because doesn't enough cpu time.

the question:

it possible somehow "reserve" 1 core "realtime" thread, , limit other threads (tasks) other cores?

  • of course, there other processes running, consuming cpu time well, let's assume consume little , constant resources.
  • this real problem can solved "throw more cpu on it"... not option...

edit - answering many useful comments:

  • we use winpcap capture packets, can many (many).
  • the "realtime" thread not "realtime" (i think "realtime" processes - in .net threadpriority uses "normal", "abovenormal", etc..)
  • the "realtime" thread calls winpcap serially, packet after packet. suspect since starved enough, doesn't keep up, , winpcap's buffer overflowed.

you can specify affinity mask processes , threads. allows prevent scheduler using specific processors. set thread affinity mask 1 thread single processor, , set thread affinity mask other threads processors other reserved processor. since .net insulates directly creating system threads not easy impose necessary masks on system threads.

another way persuade scheduler give critical thread special treatment boost priority. should care , significant forethought. however, it's simpler way make sure thread never has wait other threads in process.

perhaps better app use fewer threads processors, create dedicated thread critical work. way avoid affinity mask or priority skullduggery , let system's thread scheduler work


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -