HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: child thread blocking parent
Operating System - HP-UX
1833325
Members
2980
Online
110051
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 04:37 AM
06-26-2003 04:37 AM
I am trying to write a simple multithreaded sockets server.
pthread_create returns 0 and creates and excutes the child thread ok.
Whilst the child thread is executing though , itseems to block the parent thread from continuing (which I don't think it should do) and from accepting a further connection.
Only when the child thread has finished executing , is the parent able to continue executing and accept another connection.
I am compiling : cc -Ae -D_POSIX_C_SOURCE=199506L -o stst.exe stst.c -lpthread on an HP=UX 11i
Any advice on how to prevent the child thread from blocking the parent would be appreciated.
Julian
pthread_create returns 0 and creates and excutes the child thread ok.
Whilst the child thread is executing though , itseems to block the parent thread from continuing (which I don't think it should do) and from accepting a further connection.
Only when the child thread has finished executing , is the parent able to continue executing and accept another connection.
I am compiling : cc -Ae -D_POSIX_C_SOURCE=199506L -o stst.exe stst.c -lpthread on an HP=UX 11i
Any advice on how to prevent the child thread from blocking the parent would be appreciated.
Julian
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 04:45 AM
06-26-2003 04:45 AM
Re: child thread blocking parent
Hi,
It is normal !!! In your code, you do a pthread_create, and then a pthread_join. Take a look in man page, this function wait for the completion of the thread !! So you primary thread launch a thread, and wait that this thread has finished. Why do you put this pthread_join at this stage ? It should be somewhere else to wait the end of each thread, not in your launching function.
Cheers.
It is normal !!! In your code, you do a pthread_create, and then a pthread_join. Take a look in man page, this function wait for the completion of the thread !! So you primary thread launch a thread, and wait that this thread has finished. Why do you put this pthread_join at this stage ? It should be somewhere else to wait the end of each thread, not in your launching function.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 04:54 AM
06-26-2003 04:54 AM
Re: child thread blocking parent
Julian,
pthread_join() will wait for the thread it created. It is blocking and waiting for the thread to be finished. So, whatever you are experiencing is correct.
You are also calling pthread_detach(). This you have to do after creating the thread. Then write the code for the parent thread. Call pthread_join() at the end of the show to let the child thread join parent thread.
Read the man pages of pthread_join, pthread_create and pthread_detach for more info.
HTH,
Umapathy
pthread_join() will wait for the thread it created. It is blocking and waiting for the thread to be finished. So, whatever you are experiencing is correct.
You are also calling pthread_detach(). This you have to do after creating the thread. Then write the code for the parent thread. Call pthread_join() at the end of the show to let the child thread join parent thread.
Read the man pages of pthread_join, pthread_create and pthread_detach for more info.
HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2003 05:02 AM
06-26-2003 05:02 AM
Solution
Julian,
The fix will be like this.
Whenever you are creating the thread, store the thread_handle in a datastructure. When the socket server goes down, go in a loop for the number of threads created so far and call pthread_join() with those thread handles to wait for the threads one by one.
HTH,
Umapathy
The fix will be like this.
Whenever you are creating the thread, store the thread_handle in a datastructure. When the socket server goes down, go in a loop for the number of threads created so far and call pthread_join() with those thread handles to wait for the threads one by one.
HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP