diff options
| author | Eli Zaretskii | 2012-10-01 23:09:30 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-10-01 23:09:30 +0200 |
| commit | ace917bddb2ed2448a97ddf279445bb581c5cd32 (patch) | |
| tree | 87251631fad0dc08773200fb5936654b0620cb8d /src | |
| parent | 9eb71b9c7d0c43c02ccbfe3a45ba6d84cd8e40ed (diff) | |
| download | emacs-ace917bddb2ed2448a97ddf279445bb581c5cd32.tar.gz emacs-ace917bddb2ed2448a97ddf279445bb581c5cd32.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32proc.c | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ee7543a2830..7061038fdec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-10-01 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32proc.c (timer_loop): Fix code that waits for timer | ||
| 4 | expiration, to avoid high CPU usage. | ||
| 5 | |||
| 1 | 2012-10-01 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2012-10-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * fns.c (check_hash_table, get_key_arg, maybe_resize_hash_table) | 8 | * 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) | |||
| 333 | Sleep (sleep_time * 1000 / CLOCKS_PER_SEC); | 333 | Sleep (sleep_time * 1000 / CLOCKS_PER_SEC); |
| 334 | /* Always sleep past the expiration time, to make sure we | 334 | /* Always sleep past the expiration time, to make sure we |
| 335 | never call the handler _before_ the expiration time, | 335 | never call the handler _before_ the expiration time, |
| 336 | always slightly after it. Sleep(0) relinquishes the rest | 336 | always slightly after it. Sleep(5) makes sure we don't |
| 337 | of the scheduled slot, so that we let other threads | 337 | hog the CPU by calling 'clock' with high frequency, and |
| 338 | work. */ | 338 | also let other threads work. */ |
| 339 | while (clock () < expire) | 339 | while (clock () < expire) |
| 340 | Sleep (0); | 340 | Sleep (5); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | if (itimer->expire == 0) | 343 | if (itimer->expire == 0) |