<?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: nanosecond in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127820#M717744</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You seem to be right. I think that it's related to clock resolution too high. But gethrtime() works better although it's not related to time of day. Using these progs :&lt;BR /&gt;&lt;BR /&gt;A - no sleep() :&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;  int i;&lt;BR /&gt;  for ( i=0;i&amp;lt;3;i++)&lt;BR /&gt;  {&lt;BR /&gt;    printf("%lld nsec\n", gethrtime());&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;home&amp;gt; myprog&lt;BR /&gt;6652778157318723 nsec&lt;BR /&gt;6652778158086617 nsec&lt;BR /&gt;6652778158111862 nsec&lt;BR /&gt;&lt;BR /&gt;B - with sleep() :&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;  int i;&lt;BR /&gt;  for ( i=0;i&amp;lt;3;i++, sleep(1))&lt;BR /&gt;  {&lt;BR /&gt;    printf("%lld nsec\n", gethrtime());&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;home &amp;gt; myprog&lt;BR /&gt;6652972898147057 nsec&lt;BR /&gt;6652973900562902 nsec&lt;BR /&gt;6652974910552897 nsec&lt;BR /&gt;&lt;BR /&gt;I can really see increments around 1 second. Be careful to use %lld !!!&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;&lt;BR /&gt;&lt;/ERRNO.H&gt;&lt;/TIME.H&gt;&lt;/TIME.H&gt;</description>
    <pubDate>Tue, 25 Nov 2003 05:13:11 GMT</pubDate>
    <dc:creator>Jean-Louis Phelix</dc:creator>
    <dc:date>2003-11-25T05:13:11Z</dc:date>
    <item>
      <title>nanosecond</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127817#M717741</link>
      <description>Hi. Admins.&lt;BR /&gt;Is there any method to get nanosecond in the HP?&lt;BR /&gt;I used "gethrtime" and "clock_gettime", but they only returned "microsecond"..&lt;BR /&gt;please, Help me..&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Nov 2003 01:52:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127817#M717741</guid>
      <dc:creator>isopkim_2</dc:creator>
      <dc:date>2003-11-25T01:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: nanosecond</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127818#M717742</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;Perhaps have you been too fast when reading clock_gettime man page. It seems to be able to manage nanoseconds. You even have an example :&lt;BR /&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;struct timespec resolution;&lt;BR /&gt;if (clock_getres(CLOCK_PROFILE, &amp;amp;resolution)) {&lt;BR /&gt;perror("clock_getres(CLOCK_PROFILE) failed");&lt;BR /&gt;exit(1);&lt;BR /&gt;}&lt;BR /&gt;(void)printf("Resolution of user profiling clock is:\n");&lt;BR /&gt;(void)printf("%d seconds and %d nanoseconds.\n",&lt;BR /&gt;resolution.tv_sec, resolution.tv_nsec);&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;/ERRNO.H&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Tue, 25 Nov 2003 03:26:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127818#M717742</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-11-25T03:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: nanosecond</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127819#M717743</link>
      <description>Thanks to your answer. but,&lt;BR /&gt;I think i should have explained my questions more detail..&lt;BR /&gt;My problem is that when I wrote program like below&lt;BR /&gt;------------------------------------------&lt;BR /&gt;for ( i=0;i&amp;lt;10;i++){&lt;BR /&gt;if (clock_gettime(CLOCK_REALTIME, &amp;amp;cur_time)) {&lt;BR /&gt;        perror("clock_gettime(CLOCK_REALTIME) failed");&lt;BR /&gt;  exit(1);&lt;BR /&gt;}&lt;BR /&gt; printf("%ld nsec\n", cur_time.tv_nsec );&lt;BR /&gt;&lt;BR /&gt;the result looks like below.&lt;BR /&gt;--------------------&lt;BR /&gt;143781000 nsec&lt;BR /&gt;143811000 nsec&lt;BR /&gt;143839000 nsec&lt;BR /&gt;143868000 nsec&lt;BR /&gt;143896000 nsec&lt;BR /&gt;143923000 nsec&lt;BR /&gt;143951000 nsec&lt;BR /&gt;143978000 nsec&lt;BR /&gt;144006000 nsec&lt;BR /&gt;144033000 nsec&lt;BR /&gt;&lt;BR /&gt;The last three digits are always "0"&lt;BR /&gt;Do i have to tun some kernel parameters?&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Nov 2003 03:43:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127819#M717743</guid>
      <dc:creator>isopkim_2</dc:creator>
      <dc:date>2003-11-25T03:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: nanosecond</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127820#M717744</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You seem to be right. I think that it's related to clock resolution too high. But gethrtime() works better although it's not related to time of day. Using these progs :&lt;BR /&gt;&lt;BR /&gt;A - no sleep() :&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;  int i;&lt;BR /&gt;  for ( i=0;i&amp;lt;3;i++)&lt;BR /&gt;  {&lt;BR /&gt;    printf("%lld nsec\n", gethrtime());&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;home&amp;gt; myprog&lt;BR /&gt;6652778157318723 nsec&lt;BR /&gt;6652778158086617 nsec&lt;BR /&gt;6652778158111862 nsec&lt;BR /&gt;&lt;BR /&gt;B - with sleep() :&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;  int i;&lt;BR /&gt;  for ( i=0;i&amp;lt;3;i++, sleep(1))&lt;BR /&gt;  {&lt;BR /&gt;    printf("%lld nsec\n", gethrtime());&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;home &amp;gt; myprog&lt;BR /&gt;6652972898147057 nsec&lt;BR /&gt;6652973900562902 nsec&lt;BR /&gt;6652974910552897 nsec&lt;BR /&gt;&lt;BR /&gt;I can really see increments around 1 second. Be careful to use %lld !!!&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;&lt;BR /&gt;&lt;/ERRNO.H&gt;&lt;/TIME.H&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Tue, 25 Nov 2003 05:13:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/nanosecond/m-p/3127820#M717744</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-11-25T05:13:11Z</dc:date>
    </item>
  </channel>
</rss>

