<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic pthread scheduler in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-scheduler/m-p/2812768#M721114</link>
    <description>Dear Friends,&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;I have seen people attempting to change this variable to even 3000, generally in the cases of websites for http requests.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;According to the community, what should be the best data structures and alogorithm to incorporate such issues.&lt;BR /&gt;&lt;BR /&gt;If someone wants to answer any part of the query, he is most welcome&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Prashun</description>
    <pubDate>Tue, 24 Sep 2002 23:58:46 GMT</pubDate>
    <dc:creator>Prashun Gupta</dc:creator>
    <dc:date>2002-09-24T23:58:46Z</dc:date>
    <item>
      <title>pthread scheduler</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-scheduler/m-p/2812768#M721114</link>
      <description>Dear Friends,&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;I have seen people attempting to change this variable to even 3000, generally in the cases of websites for http requests.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;According to the community, what should be the best data structures and alogorithm to incorporate such issues.&lt;BR /&gt;&lt;BR /&gt;If someone wants to answer any part of the query, he is most welcome&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Prashun</description>
      <pubDate>Tue, 24 Sep 2002 23:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-scheduler/m-p/2812768#M721114</guid>
      <dc:creator>Prashun Gupta</dc:creator>
      <dc:date>2002-09-24T23:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: pthread scheduler</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-scheduler/m-p/2812769#M721115</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I see it like this:&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;{&lt;BR /&gt;lock( mutex );&lt;BR /&gt;queue.insert( request );&lt;BR /&gt;broadcast( cond_var );&lt;BR /&gt;unlock( mutex );&lt;BR /&gt;}&lt;BR /&gt;You make how-many-you-want threads. Threads are waiting for something to come in the queue. Use the code like:&lt;BR /&gt;&lt;BR /&gt;lock( mutex );&lt;BR /&gt;while( queue.is_empty() ) {&lt;BR /&gt;  wait( cond_var, mutex );&lt;BR /&gt;}&lt;BR /&gt;request = queue.getandunlinkfirstrequest();&lt;BR /&gt;unlock( mutex );&lt;BR /&gt;return request;&lt;BR /&gt;&lt;BR /&gt;2. If you want to clean up:&lt;BR /&gt; 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:&lt;BR /&gt;setting quit:&lt;BR /&gt;lock( mutex )&lt;BR /&gt;quit = true;&lt;BR /&gt;broadcast( cond_var );&lt;BR /&gt;unlock( mutex );&lt;BR /&gt;&lt;BR /&gt;and modify pop() to check if it is not quitting situation:&lt;BR /&gt;&lt;BR /&gt;lock( mutex );&lt;BR /&gt;while( queue.is_empty() &amp;amp;&amp;amp; ! quit ) {&lt;BR /&gt;  wait( cond_var, mutex );&lt;BR /&gt;}&lt;BR /&gt;check_if_it_was_quit_or_request();&lt;BR /&gt;if( !quit ) {&lt;BR /&gt;  request = queue.getandunlinkfirstrequest();&lt;BR /&gt;}&lt;BR /&gt;unlock( mutex );&lt;BR /&gt;return something_that_sayz_if_it_was_quit_or_request;&lt;BR /&gt;&lt;BR /&gt;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()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope it helped you somehow.&lt;BR /&gt;&lt;BR /&gt;Adam</description>
      <pubDate>Tue, 22 Oct 2002 17:26:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-scheduler/m-p/2812769#M721115</guid>
      <dc:creator>Adam J Markiewicz</dc:creator>
      <dc:date>2002-10-22T17:26:41Z</dc:date>
    </item>
  </channel>
</rss>

