URL: <http://savannah.gnu.org/bugs/?28757>
Summary: [NSThread sleepUntilDate:] in this example uses 100% of a CPU while sleeping on MinGW Project: GNUstep Submitted by: berwin Submitted on: Thu 28 Jan 2010 06:32:38 PM GMT Category: Base/Foundation Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Details: I compiled the following code on a WindowsXP machine in a MinGW environment. When I run the program, I notice that I have 25% CPU usage (I have a QUAD core machine), so that's 100% of one core. You would expect it to use near 0% of the processor since it is sleeping most of the time. I had to tweak the time variable to notice this behavior, however, and when I set it to time = 10000, the CPU usage is around 0% as I would expect. #import <Foundation/Foundation.h> #include <stdio.h> #include <Windows.h> #include <fcntl.h> int main(int argc, char *argv[], char *env[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSDate *d; NSTimeInterval time; //time = 10000; // a long time time = 10; // 10 seconds ? while (YES) { d=[NSDate dateWithTimeIntervalSinceNow: time]; [NSThread sleepUntilDate:d]; // [NSThread sleepForTimeInterval:1]; printf("one iteration\n"); } [pool release]; } _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?28757> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-gnustep mailing list Bug-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnustep