Do threads within single process share FILE streams?

Freddie Chopin freddie_chopin@op.pl
Thu Jan 22 15:12:00 GMT 2015


Hello!

I know this list is not perfect for such question, but I'm sure you know 
the answer (; I really couldn't find anything definitive on the internet...

Do threads within single process share FILE streams? I know that threads 
share file descriptors, but do they share FILE streams too? Newlib's 
source suggests that FILE streams are _NOT_ shared between threads - 
they are allocated in _reent structure, which is (I assume) per thread. 
But on the other hand - if FILE streams are not shared (implicitly), 
then the locking (with _newlib_flockfile_start() and 
_newlib_flockfile_end()) is mostly pointless and would make sense only 
when you share the FILE streams explicitly by using the same FILE 
variable from multiple threads, right?

Thanks in advance!

Regards,
FCh



More information about the Newlib mailing list