如何让 C 程序等待(在 Linux 上)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2566073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 19:54:41  来源:igfitidea点击:

How to make C program wait (on Linux)?

clinuxwaitmpi

提问by Rella

How to make C program wait (on Linux)? (I need to use wait with MPI - I need C code please)

如何让 C 程序等待(在 Linux 上)?(我需要在 MPI 中使用等待 - 我需要 C 代码)

回答by Thomas Bonini

You can use sleep(seconds)

您可以使用睡眠(秒)

回答by Paul R

Wait for whatexactly ? If you just want a delay use sleep().

究竟在等什么?如果您只想延迟使用sleep().

回答by Michael Aaron Safyan

Use MPI_Recv, and use MPI_Sendto send a message to the waiting process when it should continue.

使用MPI_Recv,并在等待进程应该继续时使用MPI_Send向其发送消息。

回答by INS

If you want to wait for a MPI request use MPI_Wait: http://www.manpagez.com/man/3/MPI_Wait/

如果您想等待 MPI 请求,请使用 MPI_Wait:http: //www.manpagez.com/man/3/MPI_Wait/

If you want to wait a certain amount of time use sleep: http://www.manpagez.com/man/3/Sleep/

如果你想等待一定的时间使用睡眠:http: //www.manpagez.com/man/3/Sleep/

If you want to wait another process to end use waitpid: http://linux.die.net/man/2/waitpid

如果你想等待另一个进程结束使用waitpid:http: //linux.die.net/man/2/waitpid

If you want to wait a condition variable (multi-threaded programming) use pthread_cond_wait: http://www.opengroup.org/onlinepubs/007908775/xsh/pthread_cond_wait.html

如果你想等待一个条件变量(多线程编程)使用 pthread_cond_wait:http: //www.opengroup.org/onlinepubs/007908775/xsh/pthread_cond_wait.html

Define what you want to wait for.

定义您要等待的内容。