分配给C过程中不同的fork()实例的不同任务 [英] DIFFERENT TASKS ASSIGNED TO DIFFERENT INSTANCES OF FORK() OF A PROCESS IN C
问题描述
我可以将不同的任务分配给C中某个进程的fork()
的不同实例吗?
例如:
Can I assign different task to different instances of fork()
of a process in C ?
like for example:
program.c
已被分叉3次
int main()
{
pid_t pid;
pid = fork();
pid = fork();
pid = fork();
}
现在对fork()
的每个实例,我想做不同的事情,我可以这样做吗?用叉子?或任何其他有利的方法? :)
now to every instance of fork()
I want to do different thing, Can I do this? with forks ? or any other method if favorable? :)
PS:我正在测试实时Linux,并希望通过时间约束通过派生检查上下文切换的性能.
PS: I am testing Real Time Linux and want to check the performance of the Context Switching through forks through Time Constraint.
推荐答案
您可以使用posix进程.
You can use posix process..
posix_spawn(& Pid,ProgramPath.c_str(),& FileActions,& SpawnAttr,argv,envp);
posix_spawn( &Pid,ProgramPath.c_str(), & FileActions,& SpawnAttr,argv,envp);
在此处.
这篇关于分配给C过程中不同的fork()实例的不同任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!