【发布时间】:2021-12-23 19:22:35
【问题描述】:
我正在根据linux manual page 使用任务集,以便仅在特定内核上运行处理非常密集的任务。
任务集被封装在一个循环中。每次选择一个新的目标目录并且任务正在运行时。并行运行该过程多次可能会导致致命的结果。
伪代码如下:
#!/bin/bash
while :
do
target_dir=$(select_dir) # select new directory to process
sudo taskset -c 4,5,6,7,8,9,10,11 ./processing_intense_task --dir $target_dir
done
如果任务集实际上等待进程完成,我在文档中没有发现任何内容。
如果不等待,如何等待任务完成后再启动processing_intense_task的新实例?
【问题讨论】:
-
你为什么会假设它不等待?
-
echo -e '#!/bin/bash\nwhile true; do echo sleep a bit; sleep 1; done' > /tmp/test.sh && chmod u+x /tmp/test.sh && taskset -c 0 /tmp/test.sh -
@KamilCuk 因为没有关于它的信息,除了任务集将设置相应的进程亲和性。我在 stack/google 上找不到任何文档或相关问题
标签: bash wait ubuntu-20.04 taskset