Do we need mutex to perform multithreading file IO
问题 I'm trying to do random write (Benchmark test) to a file using multiple threads (pthread). Looks like if I comment out mutex lock the created file size is less than actual as if Some writes are getting lost (always in some multiple of chunk size). But if I keep the mutex it's always exact size. Is my code have a problem in other place and mutex is not really required (as suggested by @evan ) or mutex is necessary here void *DiskWorker(void *threadarg) { FILE *theFile = fopen(fileToWrite, "a+"