【发布时间】:2011-04-07 09:08:07
【问题描述】:
我正在尝试创建一个程序,该程序接收一个包含 UNIX 命令列表的输入文件,并以特定顺序执行这些命令。
我正在学习fork()、wait()、execvp() 系统调用,并对等待和分叉模式有一些疑问。
这是我用于执行进程的结构。进程可以并行或顺序执行。我将在订购时决定这一点。
假设我必须按照 A、B、C、D、E 的顺序执行流程。
这是我为此提出的结构。请让我知道这是否正确。
ExecuteNodes function()
For loop {}from 0 to vector size // vector - this is the data structure that will have all the input file details
{
For loop {}// this is for my ordering logic. For all nodes I calculate the number of nodes that can execute paralley . Also using this loop to set the nodes ready for execution
For loop {
if that node is ready for execution.
run a loop for the number of concurrent processes for that node .
pid = fork()
if(pid == 0)
execvp();
}
}
for loop {all nodes}
{
wait()
}
这个结构正确吗?请让我知道您的建议/cmets。
【问题讨论】:
标签: c++