delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/25/08:54:45

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <430DBF87.2000700@exmsft.com>
Date: Thu, 25 Aug 2005 14:54:31 +0200
From: Keith Moore <keithmo AT exmsft DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Problems with Windows threads and cygwin sleep()
References: <20050824185143 DOT 76C69A01 AT data DOT zone DOT ee> <Pine DOT LNX DOT 4 DOT 62 DOT 0508241458460 DOT 26825 AT ns DOT pyerotechnics DOT com> <430D688D DOT 1070205 AT vihmapuu DOT ee> <Pine DOT CYG DOT 4 DOT 58 DOT 0508251054550 DOT 1272 AT mordor> <430D8FC8 DOT 8090906 AT vihmapuu DOT ee> <20050825100234 DOT GL17452 AT calimero DOT vinschen DOT de> <430DA017 DOT 5000402 AT vihmapuu DOT ee> <20050825115019 DOT GP17452 AT calimero DOT vinschen DOT de> <Pine DOT CYG DOT 4 DOT 58 DOT 0508251456520 DOT 2676 AT mordor> <20050825120922 DOT GQ17452 AT calimero DOT vinschen DOT de>
In-Reply-To: <20050825120922.GQ17452@calimero.vinschen.de>
X-ELNK-Trace: bd47eb33e10cdf15d780f4a490ca69563f9fea00a6dd62bc5af937acc870dbe2eacd97ef0c260d9d350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c
X-IsSubscribed: yes

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019