多用户和多处理器环境是否适用于线程?

时间:2022-12-14 20:59:16

Taking CPU affinity into account, will such an environment be useful with threading? Or will there be a performance degradation in such a system, if multiple users login and spawn multiple kernel and user threads?

考虑到CPU亲和力,这样的环境对线程有用吗?或者,如果多个用户登录并生成多个内核和用户线程,这样的系统会出现性能下降吗?

1 个解决方案

#1


2  

When you say "taking CPU affinity into account" - are you saying that all processes have CPU affinity in this hypothetical system? Or is that just as one extra possible bit of information?

当你说“考虑CPU亲和力”时 - 你是说在这个假设的系统中所有进程都具有CPU亲和力?或者这只是一个额外可能的信息?

Using multiple threads will slow things down a bit if the system is already loaded (so there are more runnable threads than cores) but if there are often times where there are only (say) 2 users and 4 cores available, threading may help.

如果系统已经加载,那么使用多个线程会使事情变慢一些(因此有比线程更多的可运行线程)但是如果经常有(例如)2个用户和4个核心可用,则线程可能会有所帮助。

Another typical use for threads is to do something "in the background" whether that's explicitly using threads or using async calls. At that point multi-threading can definitely give a benefit (e.g. a non-hanging UI) without actually using more than one core simultaneously for much of the time.

线程的另一个典型用法是“在后台”执行某些操作,无论是显式使用线程还是使用异步调用。此时,多线程绝对可以带来好处(例如,非挂起的UI),而在大多数情况下不会同时实际使用多个核心。

#1


2  

When you say "taking CPU affinity into account" - are you saying that all processes have CPU affinity in this hypothetical system? Or is that just as one extra possible bit of information?

当你说“考虑CPU亲和力”时 - 你是说在这个假设的系统中所有进程都具有CPU亲和力?或者这只是一个额外可能的信息?

Using multiple threads will slow things down a bit if the system is already loaded (so there are more runnable threads than cores) but if there are often times where there are only (say) 2 users and 4 cores available, threading may help.

如果系统已经加载,那么使用多个线程会使事情变慢一些(因此有比线程更多的可运行线程)但是如果经常有(例如)2个用户和4个核心可用,则线程可能会有所帮助。

Another typical use for threads is to do something "in the background" whether that's explicitly using threads or using async calls. At that point multi-threading can definitely give a benefit (e.g. a non-hanging UI) without actually using more than one core simultaneously for much of the time.

线程的另一个典型用法是“在后台”执行某些操作,无论是显式使用线程还是使用异步调用。此时,多线程绝对可以带来好处(例如,非挂起的UI),而在大多数情况下不会同时实际使用多个核心。