LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2011, 01:36 AM   #1
rosna
LQ Newbie
 
Registered: Jun 2011
Posts: 1

Rep: Reputation: Disabled
How to communicate between two threads using message queue?


How to communicate between two threads using message queue?Please give an example code for that.
 
Old 06-07-2011, 02:07 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi and welcome to LQ.

This is not an LFS related question, I've asked a moderator to move it to an appropriate sub-forum.
 
0 members found this post helpful.
Old 06-07-2011, 06:41 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved to Programming.

As a moderator I have done that.
 
Old 06-07-2011, 07:24 AM   #4
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by rosna View Post
How to communicate between two threads using message queue?Please give an example code for that.
LQ is not a software factory; thus providing code is not what we do.

Therefore, what have you done thus far for your project? Have you at least set up the two threads? If you are using C or C++, then look into using pthread_create() for setting up the threads, and mq_open(), mq_send(), etc. for the message queues.

Note that message queues are suitable for inter-process communications, but for a multi-threaded application, I would suggest that you consider some other alternative (say a "queue").
 
Old 06-07-2011, 08:34 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Unfortunately, your question as-written is like asking, "how do I drive from one city to another using a car?"

First: there is no answer to that question, because it is much too vague.

Second: have you actually looked for any existing examples (there are thousands...) on the Internet of how to do inter-process and inter-thread communication in Linux? (Didn't think so. You should try it sometime.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
use of events to communicate between threads in QT navderm Programming 1 01-09-2009 08:48 PM
Is it possible for me to write in front of queue in case of message queue? hemanthv414 Linux - Newbie 1 11-17-2008 04:40 PM
Message Queue sarcastodon Programming 0 12-26-2006 10:09 AM
How to communicate between two threads stephenwalter Programming 6 05-17-2006 03:35 AM
Qmail Message Queue dadepfan Linux - Software 0 07-22-2004 03:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration