<?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 Re: Anyway to prevent busy waiting? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491309#M214955</link>
    <description>Semaphores are made to do this sort of thing. In your case, your would do a semop with IPC_NOWAIT set to false so that the process is suspended until another cooperating process adjusts the semval. Man semop for details. The other mechansism that you might want to use is wait(). The idea is that you would spawn a child process to do some processing and then exit and that would reawaken the calling process. Man 2 wait for details.&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Feb 2005 21:47:17 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2005-02-22T21:47:17Z</dc:date>
    <item>
      <title>Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491306#M214952</link>
      <description>I got a program which is written to wait for a condition to be meet before it will proceed with its job &lt;BR /&gt;say:&lt;BR /&gt;while (TRUE){&lt;BR /&gt;if ( Condition = TRUE){&lt;BR /&gt; do procedure();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;so it will loop endlessly waiting for the condition to be met. Is there any other way to do this preventing unnecessary tying up of the CPU? Semaphore maybe?</description>
      <pubDate>Tue, 22 Feb 2005 19:49:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491306#M214952</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-02-22T19:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491307#M214953</link>
      <description>Well, you could put in a sleep command in your loop - "sleep 60" inside of your loop will make the loop wait 1 minute before continuing with the next check...</description>
      <pubDate>Tue, 22 Feb 2005 20:04:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491307#M214953</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2005-02-22T20:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491308#M214954</link>
      <description>Hi John, thanks for the input. Just for my info, is there anyway I can run the process on the background and let it behave like an interrupt so that it will not tied un unnecessary CPU time but yet constantly waiting for the right condition?</description>
      <pubDate>Tue, 22 Feb 2005 21:23:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491308#M214954</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-02-22T21:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491309#M214955</link>
      <description>Semaphores are made to do this sort of thing. In your case, your would do a semop with IPC_NOWAIT set to false so that the process is suspended until another cooperating process adjusts the semval. Man semop for details. The other mechansism that you might want to use is wait(). The idea is that you would spawn a child process to do some processing and then exit and that would reawaken the calling process. Man 2 wait for details.&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 21:47:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491309#M214955</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-22T21:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491310#M214956</link>
      <description>Hi Stephenson,&lt;BR /&gt;&lt;BR /&gt; Thanks for the info. Just a thought, if the cue for the execution of the procedure lies in whether a file is modified or not. Is it possible to utilise sempahore in this application? this seems to be a gray as the file may not be tied up by any process most of the time.. &lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Henry</description>
      <pubDate>Tue, 22 Feb 2005 22:52:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491310#M214956</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-02-22T22:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491311#M214957</link>
      <description>While a file can serve the purpose of a semaphore, it would have the same problem as your original code. The only way to know if a file has been modified is to test in a loop. Unlike with semaphores, there is no mechanism to "wake" a process when a file has been modified.</description>
      <pubDate>Wed, 23 Feb 2005 09:56:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491311#M214957</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-23T09:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Anyway to prevent busy waiting?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491312#M214958</link>
      <description>Thank guys for all your input, guess i still have to resort to using a loop at the end of the day..&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 22:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/anyway-to-prevent-busy-waiting/m-p/3491312#M214958</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-02-23T22:28:09Z</dc:date>
    </item>
  </channel>
</rss>

