Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8146731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:06:09+00:00 2026-06-06T14:06:09+00:00

i have an issue with synchronizing Master/slaves processes using MPI. I wish that the

  • 0

i have an issue with synchronizing Master/slaves processes using MPI.
I wish that the master control the order of the execution of the slaves. Eeach slave have to do : 1- read 2-process.
Here is my code :

int main(int argc, char* argv []){

int rank,numprocess;

MPI_Init( &argc, &argv );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
MPI_Comm_size( MPI_COMM_WORLD, &numprocess );


if(rank==0){ //master

    MPI_Status s;int Sstate=1;int Rstate;

    int p;
    for(p=1;p<numprocess;p++){

        fflush(stdout);printf("master : order P%d to start reading\n",p);
        MPI_Send(&Sstate, sizeof(int), MPI_INT, p, 20, MPI_COMM_WORLD);

        MPI_Recv(&Rstate,sizeof(int),MPI_INT,p,21,MPI_COMM_WORLD,&s);
        fflush(stdout);printf("master : P%d finished reading\n",p);
    }

}
else{ //workers

    int state; MPI_Status s;
    MPI_Recv(&state,sizeof(int),MPI_INT,0,20,MPI_COMM_WORLD,&s);

    //read here
    Sleep(1000);

    //send to master : finish reading
    state=2;
    MPI_Send(&state, sizeof(int), MPI_INT, 0, 21, MPI_COMM_WORLD);

    //processing
    Sleep(3000);
    fflush(stdout);printf("worker %d ended processing\n",rank);
}

MPI_Finalize();
return 0;
}

My probleme is with the last process. In fact it didn’t act like the others. here is my output :

mpiexec -n 4 master.exe
master : order P1 to start reading 
master : p1 finished reading
master : order P2 to start reading 
master : p2 finished reading
master : order P3 to start reading 
worker 1 ended processing 
worker 2 ended processing 
master : p3 finished reading
worker 3 ended processing 

Why the third process is not synchronized?
Thank you for precious help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:06:10+00:00Added an answer on June 6, 2026 at 2:06 pm

    What you’ve shown is Normal for a multi-threaded or multi-process architecture. Basically, after your processes call MPI_Send to the master process, they are released to function on their own as they have no more blocking MPI calls. Thus after they sleep they print their end statement, independently from one another and the master itself!

    Below I have a diagram which I hope will illustrate what you’re seeing:

    Prints happen independently

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have done drag and drop using with jquery. here i have issue that
I have issue, after checkout on checkout/onepage/success get a user info using order id,
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue using jquerys selectors when it comes to a page I
I have issue wuth Firefox not displaying style text-decoration: line-through. I am using jqGrid
i have issue regarding Paging using filterexpression. here's the piece of code for filtering
MSSQL database. I have issue to create database using old databases data. Old database
I have issue with a value that should have just work, however, it seem
I have a legacy (solve this problem for us issue) app that communicates with
I have a Spring MVC app where I am using a singleton bean that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.