HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: pthread scheduler
Operating System - HP-UX
1833777
Members
1948
Online
110063
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
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
09-24-2002 04:58 PM
09-24-2002 04:58 PM
pthread scheduler
Dear Friends,
I have been in mid of a porting project to migrate my application from task library to pthread library. I have a requirement where i need some suggestions, that is as follows
1. I have define n number of worker threads in my application. Now lets consider I am getting thread requests(tasks) spontaneously, which is more than the number of worker threads. I need to create a sort of buffer to store such requests. Now I need to push my tasks waiting in the queue to acquire a worker thread as soon as any one of the task given to worker thread completes. Now I can not use my main() to incorporate scheduling this pop/push into buffer. I need another scheduler to take care of my buffer management.
2. Just consider in case I use inbuild pthread scheduler and use more number of worker threads by increasing max_thread_proc, and allocate a seperate thread for each task, Do this is consider as right strategy.
I have seen people attempting to change this variable to even 3000, generally in the cases of websites for http requests.
2b. If 2a sounds good then I need to make a strategy to cleanup a thread resources, and make it available to next coming requests. I just wanted to make sure whether pthread_detach() function will be able to proceed in such conditions.
According to the community, what should be the best data structures and alogorithm to incorporate such issues.
If someone wants to answer any part of the query, he is most welcome
Regards
Prashun
I have been in mid of a porting project to migrate my application from task library to pthread library. I have a requirement where i need some suggestions, that is as follows
1. I have define n number of worker threads in my application. Now lets consider I am getting thread requests(tasks) spontaneously, which is more than the number of worker threads. I need to create a sort of buffer to store such requests. Now I need to push my tasks waiting in the queue to acquire a worker thread as soon as any one of the task given to worker thread completes. Now I can not use my main() to incorporate scheduling this pop/push into buffer. I need another scheduler to take care of my buffer management.
2. Just consider in case I use inbuild pthread scheduler and use more number of worker threads by increasing max_thread_proc, and allocate a seperate thread for each task, Do this is consider as right strategy.
I have seen people attempting to change this variable to even 3000, generally in the cases of websites for http requests.
2b. If 2a sounds good then I need to make a strategy to cleanup a thread resources, and make it available to next coming requests. I just wanted to make sure whether pthread_detach() function will be able to proceed in such conditions.
According to the community, what should be the best data structures and alogorithm to incorporate such issues.
If someone wants to answer any part of the query, he is most welcome
Regards
Prashun
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2002 10:26 AM
10-22-2002 10:26 AM
Re: pthread scheduler
Hi
I see it like this:
1. You make a queue of incomming requests. Together with this queue you combine a mutex and conditional variable. The push() is designed like this:
{
lock( mutex );
queue.insert( request );
broadcast( cond_var );
unlock( mutex );
}
You make how-many-you-want threads. Threads are waiting for something to come in the queue. Use the code like:
lock( mutex );
while( queue.is_empty() ) {
wait( cond_var, mutex );
}
request = queue.getandunlinkfirstrequest();
unlock( mutex );
return request;
2. If you want to clean up:
first of all mechanism to force threads to quit - add another field that says that your application is quitting. combine it with synchronisation from above:
setting quit:
lock( mutex )
quit = true;
broadcast( cond_var );
unlock( mutex );
and modify pop() to check if it is not quitting situation:
lock( mutex );
while( queue.is_empty() && ! quit ) {
wait( cond_var, mutex );
}
check_if_it_was_quit_or_request();
if( !quit ) {
request = queue.getandunlinkfirstrequest();
}
unlock( mutex );
return something_that_sayz_if_it_was_quit_or_request;
And the last thing: waiting for threads: The way I'd make it is define class with the destructor doing this thing and making statical object of this class. The destructor would be called after return from main()
Hope it helped you somehow.
Adam
I see it like this:
1. You make a queue of incomming requests. Together with this queue you combine a mutex and conditional variable. The push() is designed like this:
{
lock( mutex );
queue.insert( request );
broadcast( cond_var );
unlock( mutex );
}
You make how-many-you-want threads. Threads are waiting for something to come in the queue. Use the code like:
lock( mutex );
while( queue.is_empty() ) {
wait( cond_var, mutex );
}
request = queue.getandunlinkfirstrequest();
unlock( mutex );
return request;
2. If you want to clean up:
first of all mechanism to force threads to quit - add another field that says that your application is quitting. combine it with synchronisation from above:
setting quit:
lock( mutex )
quit = true;
broadcast( cond_var );
unlock( mutex );
and modify pop() to check if it is not quitting situation:
lock( mutex );
while( queue.is_empty() && ! quit ) {
wait( cond_var, mutex );
}
check_if_it_was_quit_or_request();
if( !quit ) {
request = queue.getandunlinkfirstrequest();
}
unlock( mutex );
return something_that_sayz_if_it_was_quit_or_request;
And the last thing: waiting for threads: The way I'd make it is define class with the destructor doing this thing and making statical object of this class. The destructor would be called after return from main()
Hope it helped you somehow.
Adam
I do everything perfectly, except from my mistakes
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