LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-14-2009, 01:14 PM   #1
spotmax777
LQ Newbie
 
Registered: Jun 2007
Posts: 5

Rep: Reputation: 0
Unhappy pthread_create() spawns 2 threads upon first call (what is the first thread?)


Hello All,

I have an application running in an embedded Linux system that calls pthread_create() multiple times to create multiple threads. For some reason, the first time I call pthread_create(), I see two pid's added when I execute the "ps" command at the Linux console. The second thread is the one that I actually intended to spawn. I don't know what the first thread is doing and what it is for.

Why is this happening? How can I prevent the extraneous thread from being created? How do I find out information on what this thread is for?

Best Regards,
Jerry
 
Old 01-14-2009, 03:09 PM   #2
spotmax777
LQ Newbie
 
Registered: Jun 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Smile ANSWER: pthread manager process

A bit of research revealed that the first time pthread_create is called, Linux will create a pthread manager process that manages threads of a process. Not sure what it does, but I guess I don't care as long as I know what it is. I'll assume it's not doing anything bad

Best Regards,
Jerry
 
Old 01-15-2009, 06:37 AM   #3
geek_comp
LQ Newbie
 
Registered: Feb 2006
Location: Hamirpur
Distribution: Fedora, Suse, Debian
Posts: 6

Rep: Reputation: 0
Smile

Yes. you are correct. its the mediator thread created once for first thread creation for a process.
On Desktop linux machine I cant see this extra thread. but on development board I could see it with all processes creating threads. Dont know exactly why ? its depends on library implementation(included) with complier.

BRegards
geek
 
  


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
Closing file descriptor for sshd that spawns remote threads Brad.Scalio@noaa.gov Linux - Software 3 06-02-2008 12:56 PM
my process needs a thread counter for detached threads Thinking Programming 6 01-25-2006 03:32 AM
Thread Ranking/Unresolved Threads jacobt LQ Suggestions & Feedback 6 12-30-2005 01:49 PM
Record for largest thread? Favorite threads? readsomestuff General 2 06-17-2005 09:59 PM
pthread_create creates a number of threads with same tid!!!! dravya Programming 5 08-11-2004 03:18 PM

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

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