<?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 Thread Pool Engine version 1.33 ... in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Thread-Pool-Engine-version-1-33/m-p/835526#M1596</link>
    <description>&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been testing all the night , and i have discovered a &lt;BR /&gt;problem, look at the following in the execute() method inside &lt;BR /&gt;my Thread Pool Engine:&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;&lt;/P&gt;&lt;P&gt;var&lt;BR /&gt;local_balance,local_count:integer;&lt;BR /&gt;params: PParams;&lt;BR /&gt;p:pointer;&lt;/P&gt;&lt;P&gt;begin&lt;BR /&gt;new(params);&lt;BR /&gt;setlength(params^,1);&lt;BR /&gt;params^[0].proc:=func;&lt;BR /&gt;params^[0].data:=context;&lt;/P&gt;&lt;P&gt;local_balance:=LockedIncLong(balance1) mod FThreadCount;&lt;BR /&gt;1-local_count:=Queues[local_balance].count; &lt;BR /&gt;2-while not Queues[local_balance].push(tobject(params^)) do;&lt;BR /&gt;3-if local_count=0 then events[local_balance].setevent;&lt;BR /&gt;p:=params;&lt;BR /&gt;dispose(p);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If local_count is not zero and between 1-3 the worker thread &lt;BR /&gt;have poped all the objects from the queue and it enters in a &lt;BR /&gt;waiting state, the event will not be signaled from the producer ,&lt;BR /&gt;and there is a possibility of a 'deadlock'.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So i have changed it to the following, to avoid the deadlock:&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;&lt;/P&gt;&lt;P&gt;var&lt;BR /&gt;local_balance,local_count:integer;&lt;BR /&gt;params: PParams;&lt;BR /&gt;p:pointer;&lt;/P&gt;&lt;P&gt;begin&lt;BR /&gt;new(params);&lt;BR /&gt;setlength(params^,1);&lt;BR /&gt;params^[0].proc:=func;&lt;BR /&gt;params^[0].data:=context;&lt;/P&gt;&lt;P&gt;local_balance:=LockedIncLong(balance1) mod FThreadCount;&lt;BR /&gt;//local_count:=Queues[local_balance].count; &lt;BR /&gt;while not Queues[local_balance].push(tobject(params^)) do;&lt;BR /&gt;//if local_count=0 then events[local_balance].setevent;&lt;BR /&gt;events[local_balance].setevent;&lt;BR /&gt;p:=params;&lt;BR /&gt;dispose(p);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can download my Thread Pool Engine ,and the other modules &lt;BR /&gt;that use it, from:&lt;/P&gt;&lt;P&gt;&lt;A href="http://pages.videotron.com/aminer/"&gt;http://pages.videotron.com/aminer/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sincerely,&lt;BR /&gt;Amine Moulay Ramdane.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2010 04:14:54 GMT</pubDate>
    <dc:creator>aminer10</dc:creator>
    <dc:date>2010-04-22T04:14:54Z</dc:date>
    <item>
      <title>Thread Pool Engine version 1.33 ...</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Thread-Pool-Engine-version-1-33/m-p/835526#M1596</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been testing all the night , and i have discovered a &lt;BR /&gt;problem, look at the following in the execute() method inside &lt;BR /&gt;my Thread Pool Engine:&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;&lt;/P&gt;&lt;P&gt;var&lt;BR /&gt;local_balance,local_count:integer;&lt;BR /&gt;params: PParams;&lt;BR /&gt;p:pointer;&lt;/P&gt;&lt;P&gt;begin&lt;BR /&gt;new(params);&lt;BR /&gt;setlength(params^,1);&lt;BR /&gt;params^[0].proc:=func;&lt;BR /&gt;params^[0].data:=context;&lt;/P&gt;&lt;P&gt;local_balance:=LockedIncLong(balance1) mod FThreadCount;&lt;BR /&gt;1-local_count:=Queues[local_balance].count; &lt;BR /&gt;2-while not Queues[local_balance].push(tobject(params^)) do;&lt;BR /&gt;3-if local_count=0 then events[local_balance].setevent;&lt;BR /&gt;p:=params;&lt;BR /&gt;dispose(p);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If local_count is not zero and between 1-3 the worker thread &lt;BR /&gt;have poped all the objects from the queue and it enters in a &lt;BR /&gt;waiting state, the event will not be signaled from the producer ,&lt;BR /&gt;and there is a possibility of a 'deadlock'.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So i have changed it to the following, to avoid the deadlock:&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;&lt;/P&gt;&lt;P&gt;var&lt;BR /&gt;local_balance,local_count:integer;&lt;BR /&gt;params: PParams;&lt;BR /&gt;p:pointer;&lt;/P&gt;&lt;P&gt;begin&lt;BR /&gt;new(params);&lt;BR /&gt;setlength(params^,1);&lt;BR /&gt;params^[0].proc:=func;&lt;BR /&gt;params^[0].data:=context;&lt;/P&gt;&lt;P&gt;local_balance:=LockedIncLong(balance1) mod FThreadCount;&lt;BR /&gt;//local_count:=Queues[local_balance].count; &lt;BR /&gt;while not Queues[local_balance].push(tobject(params^)) do;&lt;BR /&gt;//if local_count=0 then events[local_balance].setevent;&lt;BR /&gt;events[local_balance].setevent;&lt;BR /&gt;p:=params;&lt;BR /&gt;dispose(p);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can download my Thread Pool Engine ,and the other modules &lt;BR /&gt;that use it, from:&lt;/P&gt;&lt;P&gt;&lt;A href="http://pages.videotron.com/aminer/"&gt;http://pages.videotron.com/aminer/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sincerely,&lt;BR /&gt;Amine Moulay Ramdane.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2010 04:14:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Thread-Pool-Engine-version-1-33/m-p/835526#M1596</guid>
      <dc:creator>aminer10</dc:creator>
      <dc:date>2010-04-22T04:14:54Z</dc:date>
    </item>
    <item>
      <title>Thread Pool Engine version 1.33 ...</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Thread-Pool-Engine-version-1-33/m-p/835527#M1597</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;Look at the new code:&lt;/P&gt;&lt;P&gt;1- while not Queues[local_balance].push(tobject(params^)) do; &lt;BR /&gt;2- events[local_balance].setevent; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now if between 1-2 the worker thread have poped all the objects&lt;BR /&gt;from the queue and it enters in a waiting state, the event will &lt;BR /&gt;be signaled by the producer - so no problem - &lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;If the consumer was in a waiting state , the event will be signaled&lt;BR /&gt;by the consumer - so no problem - &lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;If the consumer was doing its job poping and exxecuting, the event &lt;BR /&gt;will be signaled - so no problem here - &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And in all those cases, there will be NO deadlock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;BR /&gt;Amine Moulay Ramdane.&lt;BR /&gt;&lt;BR /&gt;. &lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2010 04:24:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Thread-Pool-Engine-version-1-33/m-p/835527#M1597</guid>
      <dc:creator>aminer10</dc:creator>
      <dc:date>2010-04-22T04:24:24Z</dc:date>
    </item>
  </channel>
</rss>

