From: Eli Zaretskii Date: Mon, 1 Oct 2012 21:09:30 +0000 (+0200) Subject: Fix high CPU usage in profiling on MS-Windows. X-Git-Tag: emacs-24.2.90~241^2~53 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ace917bddb2ed2448a97ddf279445bb581c5cd32;p=emacs.git Fix high CPU usage in profiling on MS-Windows. src/w32proc.c (timer_loop): Fix code that waits for timer expiration, to avoid high CPU usage. --- diff --git a/src/ChangeLog b/src/ChangeLog index ee7543a2830..7061038fdec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-10-01 Eli Zaretskii + + * w32proc.c (timer_loop): Fix code that waits for timer + expiration, to avoid high CPU usage. + 2012-10-01 Stefan Monnier * fns.c (check_hash_table, get_key_arg, maybe_resize_hash_table) diff --git a/src/w32proc.c b/src/w32proc.c index 4c20ca13379..58e6117a7e8 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -333,11 +333,11 @@ timer_loop (LPVOID arg) Sleep (sleep_time * 1000 / CLOCKS_PER_SEC); /* Always sleep past the expiration time, to make sure we never call the handler _before_ the expiration time, - always slightly after it. Sleep(0) relinquishes the rest - of the scheduled slot, so that we let other threads - work. */ + always slightly after it. Sleep(5) makes sure we don't + hog the CPU by calling 'clock' with high frequency, and + also let other threads work. */ while (clock () < expire) - Sleep (0); + Sleep (5); } if (itimer->expire == 0)