LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* times(2) sys call bug?
@ 2008-11-20 15:09 Joakim Tjernlund
  2008-11-20 15:37 ` Josh Boyer
  0 siblings, 1 reply; 16+ messages in thread
From: Joakim Tjernlund @ 2008-11-20 15:09 UTC (permalink / raw)
  To: linuxppc-dev Development

Why does the below program end up reporting -1
multiple seconds when times() wrap:

#include <sys/times.h>
#include <stdio.h>

main()
{
        unsigned long t1;
        clock_t t2;
        while(1){
                t1 =3D times(NULL);
                t2 =3D times(NULL);
                sleep(1);
                printf("unsigned t1:%u, clock_t t2:%d\n", t1, t2);
                if (t2 > 1000)
                        break;
        }
}
and got:

unsigned t1:4294966339, clock_t t2:-957
unsigned t1:4294966439, clock_t t2:-857
unsigned t1:4294966539, clock_t t2:-757
unsigned t1:4294966639, clock_t t2:-657
unsigned t1:4294966739, clock_t t2:-557
unsigned t1:4294967295, clock_t t2:-1
unsigned t1:4294967295, clock_t t2:-1
unsigned t1:4294967295, clock_t t2:-1
unsigned t1:4294967295, clock_t t2:-1
unsigned t1:4294967295, clock_t t2:-1
unsigned t1:43, clock_t t2:43
unsigned t1:143, clock_t t2:143
unsigned t1:243, clock_t t2:243
unsigned t1:343, clock_t t2:343
unsigned t1:443, clock_t t2:443
unsigned t1:543, clock_t t2:543
unsigned t1:643, clock_t t2:643
unsigned t1:743, clock_t t2:743
unsigned t1:843, clock_t t2:843
unsigned t1:943, clock_t t2:943
unsigned t1:1043, clock_t t2:1043

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-11-21 10:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20 15:09 times(2) sys call bug? Joakim Tjernlund
2008-11-20 15:37 ` Josh Boyer
2008-11-20 16:49   ` Joakim Tjernlund
2008-11-20 23:52     ` Paul Mackerras
2008-11-21  8:31       ` Joakim Tjernlund
2008-11-21  8:41       ` Gabriel Paubert
2008-11-21  8:47         ` Joakim Tjernlund
2008-11-21  9:03         ` Paul Mackerras
2008-11-21  9:15           ` Joakim Tjernlund
2008-11-21  9:50           ` Gabriel Paubert
2008-11-21  9:55             ` Paul Mackerras
2008-11-21 10:13             ` Joakim Tjernlund
2008-11-21  9:31       ` Joakim Tjernlund
2008-11-21  9:51         ` Paul Mackerras
2008-11-21 10:07           ` Joakim Tjernlund
2008-11-21  9:53         ` Joakim Tjernlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox