本文介绍了绑定线程处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的多线程code,系统(Linux)的移动,有时从一个处理器线程到另一个。因为我有尽可能多的线程,因为我有处理器,其缓存无效没有充分的理由,它混淆了我的跟踪活动。

When I run my multi-threaded code, the system (linux) sometimes moves the threads from one processor to another. As I have as many threads as I have processors, it invalidates caches for no good reasons and it confuses my tracing activities.

你知道如何线程绑定到处理器,以及为什么系统会做到这一点?

Do you know how to bind threads to processors, and why does a system would do this ?

推荐答案

使用()。

为什么会产生不同的处理器之间调度交换机线程?好吧,假设你的线程上次运行在处理器1,目前正在等待调度执行一次。在此期间,在不同的线程当前运行在处理器1中,但处理器2是免费的。在这种情况下,这是合理的调度的线程切换到处理器2。然而,一个复杂的调度会尽量避免处理器之间跳跃线程超过必要的。

Why would a scheduler switch threads between different processors? Well, imagine that your thread last ran on processor 1 and is currently waiting to be scheduled for execution again. In the meantime, a different thread is currently running on processor 1, but processor 2 is free. In this situation, it's reasonable for the scheduler to switch your thread to processor 2. However, a sophisticated scheduler will try to avoid "bouncing" a thread between processors more than necessary.

这篇关于绑定线程处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:48