Linux 上的处理器亲和性
感谢到目前为止所有的答案!
我有一个双核处理器,我希望所有进程都运行 在 core1 上,但只有一个。我现在知道我可以使用任务集将所有当前运行的设置为 例如,绑定到处理器 1。现在我希望安排我自己的申请 启动应用程序后立即在处理器 2 上执行。换句话说, 有没有什么方法可以告诉我的应用程序中的操作系统我希望这个特定的程序在 2 号处理器上执行?
太感谢了, 马雷卡
Thanks for all the answers so far!
I am having a Dual Core processers and I would like to have all the processes running
on core1 but one. I know now that I can use taskset to set all currently running to
be bound to processor 1 for example. Now I would like that my OWN application is scheduled
for execution on processor 2 instantly after launching the application. In other words,
is there some way to tell the OS in my application that I would like to have this particular program to be executed on processor number 2?
Thank you so much,
Mareika
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看这篇文章:
http://www.linuxjournal.com/article/6799
其中详细介绍了该主题。
简而言之,确保“init”开始与一个进程具有亲和力(它的子进程将继承),然后您将需要使用:
在程序启动后立即设置进程亲和力。
Take a look at this article:
http://www.linuxjournal.com/article/6799
Which covers the subject in detail.
In short, make sure 'init' is getting started with affinity for one proc (it's children will inherit), then you'll want to use:
To set your process affinity just after your program starts up.
您可以使用:
让进程 123 在核心 2 上运行。
You can use:
to let run process 123 on core 2.
man 任务集
man taskset
我会寻找一种方法来限制“init”进程在 cpu 1 上运行。* 由于 CPU 关联性是继承的,这应该会导致系统上的所有其他进程也在 cpu 1 上运行,直到您使用以下命令启动特定的特殊进程cpu 亲和力设置为 cpu 2。
* 或者,在系统启动后,您可以重新分配所有当前正在运行的进程的亲和力,但这似乎不太优雅。
I would look for a way to limit the 'init' process to running on cpu 1.* Since CPU affinity is inherited, this should cause every other process on the system to also run on cpu 1, until you start your specific special process with cpu affinity set for cpu 2.
* Alternatively, after the system has started, you can re-assign the affinity of all currently running processes, but that seems less elegant.