LinuxQuestions.org
Help answer threads with 0 replies.
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-13-2005, 07:10 AM   #1
sameersbn
LQ Newbie
 
Registered: Jun 2005
Location: Bangalore, India
Distribution: Fedora
Posts: 4

Rep: Reputation: 0
threading in linux


hello everybody!
i am developing a client/server application for streaming audio in linux..
i have already implemented the mp3 player and buffering...

could anybody tell me how to create threads so that the child process continues to receive the audio buffer packets while the decoding of the received buffer is done by the parent process...

as far as my understanding i think will have to use fork() to create a child process(but here a copy of the whole process will be made )..CAN the child process
access the variables of the child process and vice versa?

also is it possible for me to create a new process containing of only the code to receive the incoming buffer packets and then the parent acting upon the buffer received..

could u also send me a small piece of code of whatever suggestion so i can get along quickly?

plz help this is urgent...

thanx
sameer
 
Old 06-13-2005, 07:15 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Fork doesn't create threads, it creats processes.

What you want to use is pthreads.

Check out the pthread_create man page for information on how to get started here... but feel free to ask any specific questions you have once you get stared. Remember, you have to add the -lpthread option to gcc to get threaded code to compile.

Threads share memory space, so all your threads will be able to see your global variables. Keep in mind that if you have a reader thread and a writer thread you probably want to implement locking on your data structure so you don't get partial reads.

Last edited by jtshaw; 06-13-2005 at 07:17 AM.
 
  


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
How does linux support Hyper-Threading? oriate Linux - General 2 11-04-2005 10:22 AM
Is intel's Hyper-Threading a must for Linux ??? skouket Linux - Hardware 6 03-18-2005 06:53 PM
Linux and Threading cpus Veteq Linux - Hardware 14 12-17-2004 02:06 PM
how to do threading in linux? shrike_912 Programming 2 11-04-2004 09:45 PM
Linux threading behaviour Marius2 Programming 2 03-02-2004 12:39 PM

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

All times are GMT -5. The time now is 11:43 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