Re: Sleeping in nanos
Re: Sleeping in nanos
- Subject: Re: Sleeping in nanos
- From: Greg <email@hidden>
- Date: Sat, 3 Feb 2007 02:32:20 -0500
I'm simply using "top" on both systems, one is a MacBook Pro C2D, the
other is some fast AMD processor. Are you saying that "top" lies?
There's one thing that doesn't lie for sure, and that is the fans on
my MBP which will become quite audible.
- Greg
On Feb 3, 2007, at 2:05 AM, Terry Lambert wrote:
How is it being measured on Linux?
Is it being done as a weighted moving average on scheduler
transitions, or is it based on sleeping in the idle loop, or what?
Or is a system considered "loaded" only when there are processes on
a "ready to run" queue, waiting assignment to a CPU? If the
latter, is it loaded 100% any time the value waiting for a CPU is
non-zero, or is the load based on number of "runnable" vs. "total",
and/or does it include the currently running processes as part of
the load, etc.?
Different approaches to measuring will give different answers, and
almost all systems
If your answer is coming from "top" vs. "w" vs. "uptime" vs.
getloadavg(), you are going to get a subjective measurement.
If this is an Intel system (i.e. you are comparing the same machine
running MacOS X with one running Linux), my suggestion is to use
the TSC instruction to get cycle counts, and compare those instead
of trying to compare fictitious "load average" numbers that are
likely calculated in different ways.
-- Terry
On Feb 2, 2007, at 8:38 PM, Greg wrote:
So then why do I barely see 1% CPU utilization on linux?
- Greg
On Feb 2, 2007, at 11:05 PM, Ed Wynne wrote:
From: Greg <email@hidden>
Date: February 2, 2007 10:28:08 PM EST
To: Darwin Kernel <email@hidden>
Subject: Sleeping in nanos
Is there a way on OS X to sleep for 1000 nanoseconds without
causing 65% CPU usage? I have tried nanosleep and clock_sleep
(using TIME_RELATIVE and a REALTIME_CLOCK), and both seem to
simply cause a busy loop.
Assuming an instruction takes one cycle (some do, lots don't) and
a 2Ghz CPU, each instruction will take .5ns. That means the CPU
can run 2000 instructions, at most, while your sleeping for 1us.
Given that any kind of sleep function will be a syscall into the
kernel and invoke the scheduler, I'd be willing to bet it takes a
lot more than 2000 instructions just to put yourself to sleep and
then wake back up. Your 65% CPU usage is probably indicative of
this. It is taking longer to setup and recover from sleep than
your spending sleeping.
-Ed
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden