2

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:

  1. Every process has a msg queue (using msgget(), msgsnd, msgrcv() ) so that they can talk to each other by linux API.

  2. 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.

1 Answer 1

1

So, this process in which threads are residing will have the process queue and threads' queue, Is there any problem?

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 man on your unix/Linux installation but Since You asked for online resources, You can refer to the Online Linux Man pages for reference.

1
  • thanks for quick response. I am worrying how operating system to identify which process/thread own this Queue Id at a time since this message queue functions are always mentioned in IPC section. Maybe I am overthinking of it. :) Thanks again.
    – Joe.Z
    Commented Mar 9, 2012 at 3:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.