如何等待同一程序的多个实例完成?下面是我的场景,有什么建议或建议吗?
我需要重新启动一个正在运行的C进程。在谷歌了很长一段时间后,我发现重启只能通过fork和exec来完成(我需要新实例具有与原始实例不同的pid,因此只使用exec是行不通的)。下面是我做的序列。
Shell 1:
Bash script
1. Start the first instance(./test.exe lets say pid 100)
2. Wait for it complete(pid 100) <<< Here need to wait for all instances of test
下面是一个例子:
I am talking about general linux concurrent programming environment
Definition:
Node: a machine with a processor.
file system: can be accessed both locally and remotely.
it includes large set of files varied in random size.
Node I: Process A with multithreads access A's f
什么时候我应该在多线程编程中使用“lock”?只是锁定每个线程要修改的区域,或者锁定每个线程可以访问的区域,即使它不会被修改?
struct share_data {
/* share data */
thread_id;
}
thread 1 will exceute main() function:
Initial share data. /* need lock */
join all thread(share_data.thread_id, &status) /* access share data thread_id, lock or no
Linux
我有两个功能:functionA和functionB
这两个函数可以运行多线程,其中:
一次最多只能运行一个functionA。
一次可以运行多个functionB
functionA和functionB是排他性的,也就是说,如果functionA正在执行,那么functionB必须等待functionA完成,如果有任何functionB实例正在执行,那么functionA必须等到-- functionB的所有实例完成。
你能告诉我如何在Linux中使用线程实现这个功能吗?我尝试了很多方法,但似乎还不够清楚。
Windows
如何使用C++在Windows中完成