some functions in linux mark "thread safe" by _r (e.g. gmtime_r ) but most of the syscalls are not be marked and also not mentioned in manpages. So my question is : How can i konw whether a linux syscall is thread safe? Thank you!
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- How to let a thread communicate with another activ
- glDrawElements only draws half a quad
I think you mean "library functions"; syscalls should, by virtue of operating on the thread's kernel-side data, be thread-safe.
And the answer is: check the manual pages for the functions in question. The "_r" variants are provided specifically for functions which were non-reentrant, meaning that the extra parameters passed to them were statically declared and modified in the non-"_r" versions.
Most of glibc should be, IIRC, thread-safe, but you always need to check manual pages; or, if you don't trust those, the code itself. There's no silver bullet that will remove from you the responsibility of understanding the interfaces which you are programming against.