B
Blue Ocean
Is there any platform independent way to make a C program wait for a
certain amount of time before performing a task? I don't mean:
while(difftime(clock1, clock()) < MAGICNUMBER);
Rather, I want something that cuts down on a program's use of
processor time when it is executing, like Java's Thread.sleep(int
milliseconds) method. Currently, whenever I write programs, they take
up 50% of my processor exactly (since I have a hyperthreading
processor, the maximum any one thread can use is fifty percent, or so
I've been lead to believe). I would like to make it so that the
program takes a step every, say, 1/60th of a second, for a physics
simulation, but I would like any spare processor time to revert to the
system idle thread.
certain amount of time before performing a task? I don't mean:
while(difftime(clock1, clock()) < MAGICNUMBER);
Rather, I want something that cuts down on a program's use of
processor time when it is executing, like Java's Thread.sleep(int
milliseconds) method. Currently, whenever I write programs, they take
up 50% of my processor exactly (since I have a hyperthreading
processor, the maximum any one thread can use is fifty percent, or so
I've been lead to believe). I would like to make it so that the
program takes a step every, say, 1/60th of a second, for a physics
simulation, but I would like any spare processor time to revert to the
system idle thread.