5

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

1
  • 1
    sleep() from unistd.h? what do you mean by 'wait'? Just stop for a given amount of time or wait for another process to do something? Commented Apr 2, 2010 at 10:12

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

And if you want MPI processes to wait on each other you might want to use mpi_barrier
4

You can use sleep(seconds)

1 Comment

Or nanosleep in case he wants to wait less than a second: manpagez.com/man/2/nanosleep (it was clear from the link, but people skip right past links sometimes)
2

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.