#include #include #include "mcs-lock.h" #define N 5 int main(int argc, char *argv[]) { int i; int rank, size; MPI_Win win; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); /* printf("rank: %d, size: %d\n", rank, size); */ MCSLockInit(MPI_COMM_WORLD, &win); for (i = 0; i < N; i++) { MCSLockAcquire(win); printf("rank %d aquired lock\n", rank); MCSLockRelease(win); } printf("Done\n"); MCSLockFinalize(win); MPI_Win_free(&win); MPI_Finalize(); return 0; }