I have 3 questions about thread and process communication.
-
Can the Linux function msgget(), msgsnd(), and msgrcv() be invoked by multiple threads in one process? These functions in different threads are to attempt to access(r/w) one process’ message queue. Are all race conditions supposed to be taken care by the system? If not, is there any good method to support threads and send a message to its main thread(process)?
-
Can semop() function be used to synchronize threads in one process?
-
There is a shared memory which have the following entities to access.
- process
- several threads in one process.
Do I have to use semaphore of inter-process level and a semaphore of threads level at the same time? Any simple way to handle this?
A lot of question. 🙂 thanks.
You do not need to worry about race conditions, the system will take care of that, there is no race condition with these calls.
Yes, read more in the documentation
Any resource which is shared globally among threads or processes is subject to race conditions due to one or more threads or processes trying to access it at the very same time, So you need to synchronize the access to such a shared global resource.