简体   繁体   English

在python和java中设置线程亲和力

[英]set thread affinity in python and java

When I create a thread with Java or Python I can't find the pid among the operating system threads. 使用Java或Python创建线程时,在操作系统线程中找不到pid In fact get_ident() in Python gives me a very large number that can't be the PID. 实际上,Python中的get_ident()给了我很大的数字,不能作为PID。

In fact I need to set the process affinity of all other threads to the first processor core then I want to dedicate the other cores to my specific threads run in a program to create a real time environment. 实际上,我需要将所有其他线程的进程亲和力设置为第一个处理器内核,然后我想将其他内核专用于我在程序中运行的特定线程以创建实时环境。 The threads will be less than remaining processor cores. 线程将少于剩余的处理器内核。

As I have read in stackoverflow it is not possible in Java and there will be the esigence of native calls. 正如我在stackoverflow中所读到的那样,在Java中是不可能的,并且将存在本机调用。 Can it be done in Python or I must use C/C++? 可以用Python完成吗,还是必须使用C / C ++?

The program will be installed in a Linux machine. 该程序将安装在Linux机器上。

对于Java线程,尤其是在Linux下,存在https://github.com/OpenHFT/Java-Thread-Affinity

I'm not sure I understand what you want exactly, but in Java I remember that I could launch multiple JVM and run my java programs on different OS processes, using inter-processes communication (socket, pipe or whatever you want) to do multi-core processing and syncronization. 我不确定我确切地了解您想要什么,但是在Java中,我记得我可以启动多个JVM并在不同的OS进程上运行Java程序,使用进程间通信(套接字,管道或所需的任何东西)来完成核心处理和同步。 Knowing that, it might be possible to then set a process (whole JVM) exclusively on a core. 知道这一点之后,就有可能专门在内核上设置一个进程(整个JVM)。 You can get the PID of the JVM. 您可以获取JVM的PID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM