LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-10-2003, 12:36 PM   #1
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
communicating between pthreads


hey. i have 2 pthreads running.
one is a thread i have for handling keyboard interrupts. like if i press a 'q', it should message the other thread to stop what its doing, and if i press something else, it sends that char that i pressed to the other thread, where something else is done.
im not very sure how to do this.
while i have tried kill(pid, sig); i havent understood how to receive this signal from the calling thread. i would ideally like to pass some parameters (in this case, the char that was pressed from the thread polling for keyboard interrupts to the other).

how do i pass variables from one thread to another?

thanks in advance.
 
Old 10-10-2003, 09:18 PM   #2
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint
Posts: 216

Rep: Reputation: 31
Sounds like you want to use condition variables (pthread_cond_t). Threads programming can be tricky, so you should pick up a good book on the subject. I personally prefer "Programming with POSIX Threads" by David R. Butenhof. It's very readable, and has a nice reference in the back.
 
Old 10-10-2003, 09:37 PM   #3
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Original Poster
Rep: Reputation: 46
thanks for the suggestion - will see if i can get it from sompleace.
 
Old 10-11-2003, 10:52 AM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
If you want to read about threads..
there is a solaris pdf about posix threads..not proprietary...i ahve made it sure..
try looking for it .. if you want i can send it to you
another nice place to read about threads is:
good old stevens: UNIX Network Programming, Volume 1: Networking APIs - Sockets and XTI

some stuff is there in that books second volume ...IPC....

there are chapters dedicated to threads...
plus a must have/must read for any network programmer..
 
  


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
Communicating with the modem Manjunathbs Linux - Networking 1 05-18-2005 10:23 AM
communicating with workgroup joy310 Linux - Networking 2 09-27-2004 04:12 AM
Communicating with modem oasamostexianu Linux - Hardware 0 06-22-2004 08:01 AM
Did i stump the help on here or am i not communicating right? thejokker Linux - Newbie 2 06-15-2004 08:09 AM
communicating two machines lakshman Linux - Networking 1 02-27-2003 01:32 PM

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

All times are GMT -5. The time now is 11:27 AM.

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