Re: [問題] 用script 同時跑多隻程式
hpeter 大提到的方式
1. Makefile
all: foo bar
foo: programA
/bin/sh programA
bar: programB
/bin/sh programB
2. 執行
make -j2
或是
利用 taskset 去設定 process 的 cpu affinity,
不過應該也會有 context switch 的 overhead
程式 a 跑第一顆
taskset 0x01 -p `pidof programA`
程式 b 跑第二顆
taskset 0x02 -p `pidof programB`
.
.
※ 引述《ashin0212 (QQ毛)》之銘言:
: 大家好
: 假設我有兩隻程式 program A, program B
: 爬文之後發現用 & 可以讓他同時跑(而且one by one) :
: ex: program_A &
: program_B
: -----問題
: 小弟有很多程式要跑,但機器只有四個core..
: 如果我通通用 & ,會有很多時間花在context switch
: 有什麼判斷式,或其他方法可以一次就用最大core數 (4)
: 一有程式提前完成,就馬上送出下一個
: ----------
: 先拜謝 Orz....
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.235.152
→
10/04 22:19, , 1F
10/04 22:19, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章