summaryrefslogtreecommitdiff
path: root/thread_win32.c
AgeCommit message (Collapse)Author
2011-07-03* include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,ko1
RB_RESERVED_FD_P): added. This C API is to limit to access fds which are used by RubyVM internal. In this version of CRuby, return 1 if fd is communication pipe. If your application needs to close all file descriptors to preent resource leak, skip internal fds using this C API. We also define a macro RB_RESERVED_FD_P(fd). So you can write #ifndef RB_RESERVED_FD_P #define RB_RESERVED_FD_P(fd) 0 #endif for Ruby 1.9.2 or previous version to write compatible extensions. See [ruby-core:37727] * thread_win32.c (rb_reserved_fd_p): added (return 0 for any fds). * io.c (rb_io_initialize): raise ArgumentError if given fd is reserved by Ruby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28* thread_win32.c (native_stop_timer_thread): fixed commit miss ofusa
r32244. grep sources before changing the signature of a function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c: Stop polling in the timer thread when there areko1
no waiting thread. If there are 2 or more runnable threads, the timer thread does polling. Avoid polling makes power save for several computers (0.2W per a Ruby process, when I measured). If outside-event such as signal or Thread#kill was occuerred when the timer thread does not do polling, then wake-up the timer thread using communication-pipe (the timer thread waits this communication-pipe with select(2)). The discussion about this modification can be found from the post [ruby-core:33456] and other related posts. Note that Eric Wong and KOSAKI Motohiro give us the huge contributions for this modification. Thanks. * thread_pthread.c (rb_thread_wakeup_timer_thread): add a function. This function wakes up the timer thread using communication-pipe. * thread.c (rb_thread_stop_timer_thread): add a parameter which specify closing communication-pipe or not. * thread.c (rb_thread_terminate_all): do not stop timer thread here (ruby_cleanup() terminate timer thread). * signal.c: wake up timer thread using rb_thread_wakeup_timer_thread() from signal handler. * eval.c (ruby_cleanup): use rb_thread_stop_timer_thread(1). * process.c: use rb_thread_stop_timer_thread(0) (reuse communication-pipe). * thread_win32.c (rb_thread_wakeup_timer_thread): add a dummy function. * vm_core.h: add and fix decl. of functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-15* thread.c (do_select): Windows: no need to poll if select(2) isusa
cancelable. * thread_win32.c (native_fd_select): new function to make select(2) cancelable. * thread_win32.c (rb_w32_check_interrupt): new function for checking interrupt. * win32/win32.c (rb_w32_select_with_thread): new function. cancelable select(2). * win32/win32.c (rb_w32_select): use above function internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13* thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.kosaki
* thread_pthread.c: remove HAVE_GVL_YIELD macro. * thread_win32.c (gvl_yield): new. this fallback logic was moved from rb_thread_schedule_rec(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13* thread_pthread.c: rewrite GVL completely.kosaki
* thread_win32.c: ditto. * thread_pthread.h: ditto. * vm_core.h: ditto. * thread.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13* thread_win32.c (native_cond_signal): remove unnecessary rb_bug().kosaki
It's addional fix for r32021. [Bug #4696] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-12* atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw.nobu
* gc.c (rb_gc_set_params): VM_OBJSPACE is disabled on mignw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-07remove debugging codekosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-07fix win32 native_cond_timedwait() makes SIGSEGV.kosaki
* thread_win32.h (rb_thread_cond_struct): add prev field instead of last. (ie cond_event_entry is now using double linked list instead of single) * thread_win32.c (cond_event_entry): add prev field. * thread_win32.c (__cond_timedwait): remove entry properly if timeout was happen. * thread_win32.c (native_cond_signal): change for double linked list. * thread_win32.c (native_cond_broadcast): ditto. * thread_win32.c (native_cond_initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-07fix mutex deadlock test hang-up.kosaki
* thread_win32.c (abs_timespec_to_timeout_ms): fix 1000x calculation mistake. (ie fix hang-up native_cond_timedwait()) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-06sleep_cond use monotonic time if possible.kosaki
* thread_pthread.c (native_thread_init): change sleep_cond attribute to monotonic. * thread_pthread.c (native_sleep): use native_cond_timeout(). * thread_pthread.c (native_cond_timeout): add overflow care. * thread_win32.c (native_cond_timeout): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-06 fix win32 compile error.kosaki
* thread_win32.c (RB_CONDATTR_CLOCK_MONOTONIC): define RB_CONDATTR_CLOCK_MONOTONIC always. * thread_pthread.c (RB_CONDATTR_CLOCK_MONOTONIC): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-06 mutex: deadlock check timeout use monotonic time.kosaki
* thread_pthread.c (native_cond_timeout): new internal api. it calculate a proper time for argument of native_cond_timedwait(). * thread_win32.c (native_cond_timeout): ditto. * thread_pthread.c (thread_timer): use native_cond_timeout() instead of get_ts. * thread.c (lock_func): ditto. * thread_pthread.c (get_ts): removed. use native_cond_timeout(). * thread.c (init_lock_timeout): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-06* thread_pthread.h (rb_thread_cond_t): add clockid field. it'skosaki
no longer an alias of pthread_cond_t. * thread_pthread.c: adapt new rb_thread_cond_t type. * thread.c (mutex_alloc): ditto. * thread_win32.c (native_cond_initialize): ditto. * configure.in: add check for pthread_cond_attr_setclock() and clockid_t type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-05* thread_pthread.c (native_mutex_reinitialize_atfork): removedkosaki
unused macro. * thread_win32.c (native_mutex_reinitialize_atfork): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-29* thread_win32.c, include/ruby/win32.h: add prototypes.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-29* thread_win32.c (native_cond_timedwait): New. r31373 causedkosaki
win32 build failure. * thread_win32.c (__cond_timedwait, abs_timespec_to_timeout_ms): New helper functions. * win32/win32.c (rb_w32_time_subtract): rename from subtract and remove static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-20 * thread.c (thread_cleanup_func): Moved interrupted_lockkosaki
destroying code from native_thread_destroy() to thread_cleanup_func() because it's platform independent logic. * thread_win32.c (native_thread_destroy): ditto. * thread_pthread.c (native_thread_destroy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28* thread_win32.c (gvl_release, gvl_init): suppress warnings.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-27* thread.c, vm_core.h: make gvl_acquire/release/init/destructko1
APIs to modularize GVL implementation. * thread_pthread.c, thread_pthread.h: Two GVL implementations. (1) Simple locking GVL which is same as existing GVL. (2) Wake-up queued threads. The wake-up order is simple FIFO. (We can make several queues to support exact priorities, however this causes some issues such as priority inversion and so on.) This impl. prevents spin-loop (*1) caused on SMP environemnts. *1: Only one Ruby thread acqures GVL again and again. Bug #2359 [ruby-core:26694] * thread_win32.c, thread_win32.h: Using simple lock not by CRITICAL_SECTION but by Mutex. Bug #3890 [ruby-dev:42315] * vm.c (ruby_vm_destruct): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-27* thread_win32.c (w32_error): should get error no only once, becauseusa
the result of the second getting will indicate the error of the first FormatMessage() call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26* Makefile.in (ASFLAGS): needs INCFLAGS.nobu
* configure.in (rb_cv_dynamic_alloca): check if extra source for dynamic size alloca. * missing/x86_64-chkstk.s (___chkstk): necessary for alloca of amd64-mingw32msvc-gcc on Ubutu. * thread_win32.c (ruby_alloca_chkstk): check stack overflow git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13* thread_win32.c (w32_error): get English message first, insteadusa
of system default. see [ruby-core:32765]. [experimental] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12* configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf formatnobu
specifier if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-23* thread_win32.c (w32_wait_events, w32_close_handle): suppress warnings.wanabe
see [ruby-core:31932]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-02* thread_win32.c (native_thread_join): need to wait thread, of course.usa
[ruby-dev:41911] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-05* vm.c (Init_BareVM): call Init_native_thread here.akr
* thread.c (Init_Thread): don't call Init_native_thread. * thread_pthread.c (Init_native_thread): exported. * thread_win32.c (Init_native_thread): ditto. [ruby-dev:41536] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-05* thread_win32.c (w32_wait_events): get GVL before handle interruptwanabe
event. [ruby-core:27199], [ruby-core:29698] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-22* thread_win32.c (ubf_handle): remove unused typedef.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-04* thread_win32.c (InterlockedExchangePointer): old SDK support.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-30* thread_win32.c (native_thread_destroy): decreased the probability ofusa
using the interrupt event in the thread termination. see [ruby-core:27199]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-30* thread_win32.c (w32_error): should report the function.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-18* thread.c (rb_thread_atfork_internal): reinitialize global locknobu
at fork to get rid of deadlock. based on the patch from Hongli Lai in [ruby-core:26783]. [ruby-core:26361] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-12* thread_win32.c (thread_errno): CreateThread does not set errno.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-12* thread.c (thread_create_core): moved failure handling fromnobu
native_thread_core(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-02* thread_{pthread,win32}.c (native_stop_timer_thread): join the threadusa
here. * thread_{pthread,win32}.c (native_reset_timer_thread): new function. * thread.c (rb_thread_stop_timer_thread, rb_thread_reset_timer_thread): call above function instead of simply seting 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-19* eval.c (ruby_cleanup): the order of local variables on stack isnobu
undefined. should use outermost VALUE for ruby_init_stack. * gc.c (ruby_get_stack_grow_direction, Init_stack): allows volatile pointer. * thread_*.c (ruby_init_stack): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-22 * thread_win32.c (Init_native_thread): need to callusa
ruby_thread_set_native() here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-08* thread_pthread.c (thread_timer): checks working flags again.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-07* thread_win32.c (thread_start_func_1): use already gotten stack info.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-06* thread.c (rb_thread_stop_timer_thread): terminates timer threadnobu
immediately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 * win32/win32.c, include/ruby/win32.h (rb_w32_open): overlapped fileusa
I/O support. * win32/win32.c, include/ruby/win32.h (rb_w32_pipe): overlapped pipe I/O support. * wn32/win32.c (rb_w32_read, rb_w32_write): overlapped I/O support to enable canceling I/O. * thread_win32.c (ubf_handle): remove workaround. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13* thread.c, vm_core.h: add manual priority supportko1
using time slice. if you enable USE_NATIVE_THREAD_PRIORITY macro, this mechanism is ignored. [ruby-dev:33124] * thread_pthread.c, thread_win32.c: ditto. * test/ruby/test_thread.rb: fix test parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-28 * thread_win32.[ch] (cond_every_entry, rb_thread_cond_struct): revertedusa
r18239 because r18245 made the changes unnecessary. * thread.c (rb_mutex_struct): define after including thread_{pthread, win32}.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-28 * thread_win32.[ch]: moved definitions of cond_every_entry andusa
rb_thread_cond_struct from .c to .h because rb_thread_cond_struct is used in vm_core.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-24 * win32/win32.c (overlapped_socket_io): avoid warnings.usa
* thread_win32.c (ubf_handle): refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-16* thread.c (thread_start_func_2): wake up joining threads.nobu
* thread.c (sleep_forever, sleep_timeval): return when interrupted. [ruby-dev:35542] * thread.c (timer_thread_function): restore main thread status. [ruby-core:17270] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-15 * thread_win32.c (ubf_handle): cancel blocking IO if it can (onlyusa
Vista). see [ruby-dev:35446] * win32/win32.c (errmap): add ERROR_OPERATION_ABORTED as EINTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-09* thread.c (sleep_forever): wait until timed out. [ruby-core:17270]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e