小编tes*_*t87的帖子

用MPI C编程用餐哲学家计划

我的MPI C程序有问题.这是代码:

void wantEat(int p, int rank, char *state, char* stateLeft, char* stateRight){

    char *s;

    MPI_Status status ;

    /* if left or right neighbor is eating */

    if(compare(stateLeft, "eat") || compare (stateRight, "eat")){
        state = "want_Eat";
        printf("%s : I wait for eating\n", nomPhilosophe(rank));

        /* the process have to send his new state to his neighbors */

        MPI_Send(state, strlen(state)+1, MPI_CHAR,
                (rank - 1 + p) % p, 0, MPI_COMM_WORLD);
        MPI_Send(state, strlen(state)+1, MPI_CHAR,
                (rank + 1) % p, 0, MPI_COMM_WORLD);

        /* if …
Run Code Online (Sandbox Code Playgroud)

c parallel-processing mpi dining-philosopher

5
推荐指数
0
解决办法
700
查看次数

标签 统计

c ×1

dining-philosopher ×1

mpi ×1

parallel-processing ×1