I can use pthread_create() to kick off 7 threads, each thread contains a fprintf(unique_fid) command
However I have noticed when running the 7 threads, the fprintf command seems to use all defined unique_fid's not just the sole one assigned to a thread, so the data gets shuffled when printing.
Why are running pthreads mixing up the file descriptors?
Please show the code that exhibits the problem.
The most obvious answer:
Each thread does not have a unique file descriptor and instead you are having all threads access the same file.
How are you ensuring that each thread has a unique file?