should I “bind” “spinning” thread to the certain core?

后端 未结 5 1404
难免孤独
难免孤独 2021-02-03 11:32

My application contains several latency-critical threads that \"spin\", i.e. never blocks. Such thread expected to take 100% of one CPU core. However it seems modern operation s

5条回答
  •  无人及你
    2021-02-03 12:13

    Binding a thread to a specific core is probably not the best way to get the job done. You can do that, it will not harm a multi core CPU.

    The really best way to reduce latency is to raise the priority of the process and the polling thread(s). Normally the OS will interrupt your threads hundreds of times a second and let other threads run for a while. Your thread may not run for several milliseconds.

    Raising the priority will reduce the effect (but not eliminate it).

    Read more about SetThreadPriority and SetProcessPriorityBoost. There some details in the docs you need to understand.

提交回复
热议问题