小编aja*_*aja的帖子

同一进程的线程可以运行在不同的核心上吗?

进程产生的线程可以在多核系统的不同核心上运行吗?

假设我有一个进程 P,从中生成了两个线程 t1 和 t2,它是一个具有两个核心 C1 和 C2 的多核系统。我的问题是:

  1. t1 和 t2 是否可以与进程 P 运行在同一内存空间上?
  2. 线程 t1 是否可以在与进程 P 运行的不同内核中执行?例如:进程 P 运行在核心 C1 上,线程 t1 运行在核心 C2 上?

linux multithreading operating-system multiprocess

4
推荐指数
1
解决办法
2158
查看次数

Restart python script automatically even when it crashes in Linux

I have a python program that has to be running all the time. If for some reason it was stopped I want to restart it automatically. I thought of having a cron that will run every n number of seconds and check the program is running. My shell script is looks like this:

#!/usr/bin/env bash
CM_COMMAND=`ps aux| grep abc| grep def| grep sudo`
LEN_COMMAND=${#CM_COMMAND}
if[["$LEN_COMMAND" -le "5"]] 
then
    echo "start the python program"
fi
exit
Run Code Online (Sandbox Code Playgroud)

When I run this script …

python linux shell scripting

3
推荐指数
1
解决办法
6994
查看次数