diff options
| author | Eli Zaretskii | 2013-08-31 14:29:05 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-08-31 14:29:05 +0300 |
| commit | e57df8f77901a3964d21c3d57fb6769cf4511dc2 (patch) | |
| tree | 1a748293f62f70a786b9f6c51662e1c132650528 /src/process.c | |
| parent | dbe17fefccbff010bbbf6c4d0dccc7b2f3a5e201 (diff) | |
| download | emacs-e57df8f77901a3964d21c3d57fb6769cf4511dc2.tar.gz emacs-e57df8f77901a3964d21c3d57fb6769cf4511dc2.zip | |
Improve MS-Windows implementation of threads.
src/systhread.c (sys_cond_init): Set the 'initialized' member to
true only if initialization is successful. Initialize wait_count
and wait_count_lock.
(sys_cond_wait, sys_cond_signal, sys_cond_broadcast): If
'initialized' is false, do nothing.
(sys_cond_wait): Fix the implementation to avoid the "missed
wakeup" bug: count the waiting threads, and reset the broadcast
event once the last thread was released.
(sys_cond_signal, sys_cond_broadcast): Use SetEvent instead of
PulseEvent. Don't signal the event if no threads are waiting.
(sys_cond_destroy): Only close non-NULL handles.
(sys_thread_create): Return zero if unsuccessful, 1 if successful.
src/systhread.h (w32thread_cond_t): New member 'initialized'.
Rename waiters_count and waiters_count_lock to wait_count and
wait_count_lock, respectively.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/process.c b/src/process.c index 94ca3d4b1a0..899c0035866 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -497,7 +497,6 @@ void | |||
| 497 | delete_read_fd (int fd) | 497 | delete_read_fd (int fd) |
| 498 | { | 498 | { |
| 499 | eassert (fd < MAXDESC); | 499 | eassert (fd < MAXDESC); |
| 500 | eassert (fd <= max_desc); | ||
| 501 | delete_keyboard_wait_descriptor (fd); | 500 | delete_keyboard_wait_descriptor (fd); |
| 502 | 501 | ||
| 503 | if (fd_callback_info[fd].flags == 0) | 502 | if (fd_callback_info[fd].flags == 0) |
| @@ -559,7 +558,6 @@ delete_write_fd (int fd) | |||
| 559 | int lim = max_desc; | 558 | int lim = max_desc; |
| 560 | 559 | ||
| 561 | eassert (fd < MAXDESC); | 560 | eassert (fd < MAXDESC); |
| 562 | eassert (fd <= max_desc); | ||
| 563 | 561 | ||
| 564 | #ifdef NON_BLOCKING_CONNECT | 562 | #ifdef NON_BLOCKING_CONNECT |
| 565 | if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0) | 563 | if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0) |
| @@ -6942,7 +6940,6 @@ delete_keyboard_wait_descriptor (int desc) | |||
| 6942 | int lim = max_desc; | 6940 | int lim = max_desc; |
| 6943 | 6941 | ||
| 6944 | eassert (desc >= 0 && desc < MAXDESC); | 6942 | eassert (desc >= 0 && desc < MAXDESC); |
| 6945 | eassert (desc <= max_desc); | ||
| 6946 | 6943 | ||
| 6947 | fd_callback_info[desc].flags &= ~(FOR_READ | KEYBOARD_FD | PROCESS_FD); | 6944 | fd_callback_info[desc].flags &= ~(FOR_READ | KEYBOARD_FD | PROCESS_FD); |
| 6948 | 6945 | ||