[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #28757] [NSThread sleepUntilDate:] in this example uses 100% of a C
From: |
Brock Erwin |
Subject: |
[bug #28757] [NSThread sleepUntilDate:] in this example uses 100% of a CPU while sleeping on MinGW |
Date: |
Thu, 28 Jan 2010 18:32:39 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7 GTB7.0 |
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 #28757] [NSThread sleepUntilDate:] in this example uses 100% of a CPU while sleeping on MinGW,
Brock Erwin <=