Corinna Vinschen wrote: > You're on W2K, I'm on XP, maybe there's a difference? I can easily > reproduce nearly 0% CPU with 1000 threads if no Cygwin process is > present and nearly 99% if a Cygwin process is present. > > Even if we can't do much about it, it would be interesting to find out > how Cygwin affects CPU usage of non-Cygwin processes.
There's a big difference between POSIX sleep() and Win32 Sleep(). POSIX sleep(1) will sleep for one second. Win32 Sleep(1) will sleep for one millisecond. A Win32 app with 100 threads each doing "while(1){Sleep(1);}" will spend a lot of time a) bouncing between user- and kernel-modes, and b) doing context switches. My Laptop (3GHz P4, HT disabled) can create about 300 threads before any changes appear on the CPU load. I suspect this represents roughly the maximum working set that fit into the processor's L2 cache. This "working set" includes per-thread data (at one user-mode stack page, one kernel-mode stack page, thread context) plus more-or-less fixed overhead (code to do the kernel transitions, the scheduler code and data, other background processes, interrupt handlers, etc). Once this working set exceeds the L2 cache, the CPU will spend a lot of time waiting for system RAM. Now, why would having a Cygwin process running would affect this behavior? I have no idea. I'm not seeing this on my laptop. Of course, this is all just a theory. I could be wrong. KM -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/