功能可以在主应用程序内独立运行吗? [OpenMP] [英] Can a function run independently inside a main app? [OpenMP]
问题描述
说我们有一个不干扰其他数据并且独立运行的功能.但是,我听说有一种方法可以将整个应用程序划分为一个部分,而仅将其划分为一个部分.主应用程序可以将其生成到线程中并确保主应用程序不会等待其结束吗?
Say we have a function that does not interfere with other data and runs independently. However, I heard a method to do it is to make the whole app in to a section and that alone a section. Can it be done instead with the main app spawning it into a thread and ensuring that the main app will not wait for it to end?
例如伪代码:
int main (void) {
<do stuff on thread 0>
<do stuff on thread 0>
<spawn independent function on thread 1 with no waiting>
<do stuff on thread 0>
<do stuff on thread 0>
}
可以完全用另一种哲学来完成吗? (没有OpenMP)
Can it be done with another philosophy completely? (no OpenMP)
推荐答案
这不是OpenMP的主要目标:它是为并行处理而不是并发编程而构建的.检查您的本地线程库,并查找守护程序线程",分离线程"或类似名称.
This isn't OpenMP's prime goal: it was built for parallel processing, not concurrent programming. Check your local thread library and look for something called "daemon threads", "detached threads" or similar.
这篇关于功能可以在主应用程序内独立运行吗? [OpenMP]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!