moved critical section for mpi_serialized to threads.c