5

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

Paul R
  • 208,748
  • 37
  • 389
  • 560
Rella
  • 65,003
  • 109
  • 363
  • 636

4 Answers4

12

If you want to wait for a MPI request use 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/

If you want to wait another process to end use 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

Define what you want to wait for.

INS
  • 10,594
  • 7
  • 58
  • 89
4

You can use sleep(seconds)

Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
  • 3
    Or `nanosleep` in case he wants to wait less than a second: http://www.manpagez.com/man/2/nanosleep/ (it was clear from the link, but people skip right past links sometimes) – T.J. Crowder Apr 02 '10 at 10:17
2

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

Paul R
  • 208,748
  • 37
  • 389
  • 560
1

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

Michael Aaron Safyan
  • 93,612
  • 16
  • 138
  • 200