How do threads arranged in OS when our progress is not the only one running?

⚓ rust    📅 2025-06-04    👤 surdeus    👁️ 1      

surdeus

I'm non-English speaker so if I don't make myself clear, feel free to point it out. Thank you very much.

Considering making a multi-thread binary which requires high-performance. The common idea is to set the thread numbers to the cores number of CPU. Sometimes on hyper-threads CPU we can set to 2x. This should be the way during normal situation?

But I've been thinking of that when our program is running, there must be many OTHERS progresses running too. And also some of them are multi-thread. So, can I believe that in every "unit" of time, there are more threads than cpu cores are running.

Under this circumstance, how can we arrange numbers of threads our program use? Though I know the answer could be "CPU cores", but why?

I'm not very familiar with kernel theory of OS or CPU. So maybe this is a stupid question.

Articles or links are welcomed!

6 posts - 3 participants

Read full topic

🏷️ rust_feed