LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-12-2012, 02:31 PM   #1
dbrazeau
Member
 
Registered: Aug 2009
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184

Rep: Reputation: 28
pthread hangs after spawning x pthreads


I have an application that calls a function from main, and in that function it spawns a pthread using pthread_create (Thread 1). Then Thread 1 loops forever spawning a pthread (Thread 2), wainting for Thread 2 to return, and then respawns Thread 2. For some reason after it spawns Thread 2 76 times Thread 1 just hangs.

Is this not a valid thing to do?
Is there something else I need to do to clean up Thread 2 when it returns?
I have tried exiting Thread 2 using pthread_exit, but that didn't make any difference. Also it doesn't seem like a memory leak, since in another terminal I can start my application again which will hang at the same number of thread spawn loops.
 
Old 12-12-2012, 03:44 PM   #2
dbrazeau
Member
 
Registered: Aug 2009
Distribution: Fedora, OpenSuse, DENX Embedded Linux
Posts: 184

Original Poster
Rep: Reputation: 28
So it looks like the key piece I was missing was the pthread_join in the Thread 1. Previously I was just using a flag to determine when Thread 2 was done.
 
  


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
[SOLVED] [Pthreads]Usage of Conditions Variables with Pthreads Aquarius_Girl Programming 2 01-14-2013 05:40 AM
libtest.a uses pthread: user of libtest.a should not link pthread again debulu Programming 2 01-31-2007 09:23 PM
perl spawning many process's Xris718 Programming 2 11-01-2005 12:50 PM
Bash not spawning Norm-o Linux - General 5 04-06-2005 03:49 PM
vsftp not spawning! cjpsparks Linux - Software 0 01-25-2005 06:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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