There are several processes and some threads in one process. All processes need to talk to each other. Threads in one process need to talk to the process(main threads). I am wondering if this design works:
-
Every process has a msg queue (using msgget(), msgsnd, msgrcv() ) so that they can talk to each other by linux API.
-
Every thread has a msg queue (also using msgget, msgsnd, msgrcv ) so that it can talk to the mainthread and other threads. So, this process in which threads are residing will have the process queue and threads’ queue, Is there any problem?
I am worrying about the item 2 since what I learn is that msgget, msgsnd, msgrcv are for inter process communication. I read manual about these functions. It looks like no mentioning about if these functions are supporting threads. In addition, could you please refer me to some best online Linux/Unix manual? I am not good at it since I feel it hard to find what I am looking for like, if a function or semaphore can support thread/manual. Stupid question, :).
Please help. Thanks.
No there is no problem, Each message Queue is identified by a Queue Id which is unique and whoever, a thread or a process can provide this queue id can access the Message Queue.
If it gives you any comfort, I have used message Queue’s for thread context switching flawlessly so be assured it works.
It is usually best to just
manon your unix/Linux installation but Since You asked for online resources, You can refer to the Online Linux Man pages for reference.