Results 1 to 4 of 4
Hi All,
I have a generic, but might be basic question. I am using linux kernel 2.6. would like to know if using mq_xxxx() functions is 'thread safe' so that ...
- 07-21-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 2
mq_xxxx() functions used across phthreads
Hi All,
I have a generic, but might be basic question. I am using linux kernel 2.6. would like to know if using mq_xxxx() functions is 'thread safe' so that i can use it for inter-thread communication and synchronization. My actual concern is whether mq_xxxx() api is protected "within a process" and "across threads" itself. I am new to the pthread implementation in 2.6 kernel, so please help me with this.
I already googled, yahoo'ed, bing'ed - but couldn't get a clear answer to my query.
Thank you all in advance.
- 07-21-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Sorry, but I don't know if message queues are safe for inter-thread communication or if they are "thread safe" in the strictest sense (no process-global data). My suggestion would be to try to simulate some pernicious situations where problems would be easily detected as an experimental process. This should not be too hard to do. If it works (or not), then you have your answer and you can illuminate all of here on the forums for others that have such questions in the future.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-22-2009 #3Just Joined!
- Join Date
- Jul 2009
- Posts
- 2
Thanks, rubberman. I appreciate your suggestion. As far as the testing done by me, I could not find any issues.
This link:
people.redhat.com/~drepper/posix-option-groups.html#MESSAGE_PASSING
says "The implementation of POSIX message queues requires kernel support which got added after 2.6.5 (i.e., 2.6.6 will be the first official kernel with the support). The librt in glibc 2.3.4 after 2004-4-12 includes the necessary userlevel support."
I could only hope that it is thread safe and would like to hear from someone if they had had any issues with it. Will post here if i get any more data...
- 07-22-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
For most standard library functions that are not thread safe, there are also re-intrant ones that are thread safe, usually named funcname_r() instead of funcname(). The fact that there aren't any such in the message queue library, and the man pages makes absolutely no caveats regarding thread safety, I have to think that they most likely are thread safe. However, since they are part of the kernel, access to the source code is easy enough in order to determine if they are designed that way.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
