aboutsummaryrefslogtreecommitdiffstats
path: root/thread_win32.c
Commit message (Collapse)AuthorAgeFilesLines
* * thread_pthread.c (native_set_thread_name): New function toakr2014-09-211-0/+5
| | | | | | | | | | | | | set thread name visible with ps command on GNU/Linux. Ex. ps -o %c -L * thread.c (thread_start_func_2): Call native_set_thread_name at beginning. (rb_thread_inspect_msg): Extract from rb_thread_inspect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_pthread.c: timer thread flagnobu2014-06-111-15/+18
| | | | | | | * thread_pthread.c (timer_thread): add a flag to tell timer thread is created, since 0 may be a valid value as pthread_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Handle machine stack overflow on mingwnobu2014-05-151-0/+12
| | | | | | | | | | * thread_win32.c (rb_w32_stack_overflow_handler): use Structured Exception Handling by Addvectoredexceptionhandler() for machine stack overflow on mingw. This would be equivalent to the handling using __try and __exept on mswin introduced by r43748. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_*.c: constifynobu2014-05-091-2/+2
| | | | | | * thread_{pthread,win32}.c (native_cond_timedwait): constify. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: rb_thread_struct::machinenobu2014-01-281-3/+3
| | | | | | | * vm_core.h (rb_thread_struct): aggregate cpu stuff into a struct, so that a debugger can show its content at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * eval_intern.h (SAVE_ROOT_JMPBUF): workaround for the failure ofusa2013-11-211-0/+6
| | | | | | | | | | | | | | | | | | | test/ruby/test_exception.rb on Windows. wrap by __try and __exception statements on mswin to raise SIGSEGV when EXCEPTION_STACK_OVERFLOW is occurred, because MSVCRT doesn't handle the exception. however, (1) mingw-gcc doesn't support __try and __exception statements, and (2) we cannot retry SystemStackError after this change yet (maybe crashed) because SEH and longjmp() are too uncongenial. * signal.c (check_stack_overflow, CHECK_STACK_OVERFLOW): now defined on Windows, too. * thread_win32.c (ruby_stack_overflowed_p): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_(pthread|win32).h: rename rb_thread_cond_t toko12013-07-231-8/+8
| | | | | | | | | | rb_nativethread_cond_t. * thread.c, thread_pthread.c, thread_win32.c, vm_core.h: catch up renaming. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_native.h: add rb_nativethread_self() which returnsko12013-07-231-0/+7
| | | | | | | | | current running native thread identifier. * thread_[pthread|win32].c: implement rb_nativethread_self(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_native.h: added.ko12013-07-231-10/+10
| | | | | | | | | | | | | | | Move native thread related lines from vm_core.h. And declare several functions "rb_nativethread_lock_*", manipulate locking. * common.mk: add thread_native.h. * thread.c: add functions "rb_nativethread_lock_*". * thraed.c, thread_[pthread,win32].[ch]: rename rb_thread_lock_t to rb_nativethread_lock_t to make it clear that this lock is for native thraeds, not for ruby threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32: for strict ANSInobu2013-07-081-3/+3
| | | | | | | | | * thread_win32.c (w32_thread_start_func, thread_start_func_1), (timer_thread_func): use __stdcall instead of _stdcall which is unavailable in strict ANSI mode. [ruby-core:55312] [Bug #8495] * win32/win32.c (gettimeofday): use __cdecl instead of _cdecl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* timev.h: move time_t stuffsnobu2013-03-301-10/+0
| | | | | | | | * timev.h (TYPEOF_TIMEVAL_TV_SEC, unsigned_time_t): move from time.c. * thread.c: use definitions in timev.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Define TIMET_MAX and TIMET_MIN here.akr2013-03-261-2/+0
| | | | | | | | | | | | | | * time.c: Remove TIMET_MAX and TIMET_MIN definitions. * thread.c: Ditto. * thread_pthread.c: Remove TIMET_MAX definition. * thread_win32.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (native_sleep): suppress warning.nobu2013-03-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_win32.c: suppress warningnobu2013-02-271-8/+2
| | | | | | | * thread_win32.c (native_sleep): constify local variable to suppress a false positive might-be-clobbered warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c: catch up latest change of BLOCKING_REGION.ko12012-11-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_win32.h: rb_thread_lock_t for USE_WIN32_MUTEXnobu2012-06-171-13/+13
| | | | | | | | | * thread_win32.h (rb_thread_lock_t): make a union for USE_WIN32_MUTEX. this internal is used only in thread_win32.c, but has to be complete to define rb_thread_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_win32.c: USE_WIN32_MUTEXnobu2012-06-171-2/+2
| | | | | | | | * thread_win32.c (native_mutex_lock, native_mutex_destroy): fix for USE_WIN32_MUTEX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread_win32.c: reserved pattern namenobu2012-06-171-3/+3
| | | | | | | | * thread_win32.c (native_cond_timedwait_ms): rename reserved pattern name. user defined symbols should not start with __. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (native_thread_create): add a comment.usa2012-06-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (TIME_QUANTUM_USEC): 10ms(= old setting) [experimental]usa2012-03-291-1/+1
| | | | | | | cf. [Bug #6098] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (rb_w32_wait_events_blocking): useshirosaki2012-01-281-4/+4
| | | | | | | | | | | | | | | | | | ruby_thread_from_native() instead of GET_THREAD() because GET_THREAD() doesn't always return the current thread and WaitForMultipleObjects() at rb_w32_read() doesn't return by Thread#kill. This fixes TestQueue#test_thr_kill failure on Windows. * thread_win32.c (rb_w32_wait_events): use ruby_thread_from_native() instead of GET_THREAD() for consistency with the above change. * thread_win32.c (rb_w32_sleep): ditto. * thread_win32.c (rb_w32_Sleep): ditto. [ruby-dev:45149] [Bug #5812] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,ko12011-07-031-0/+5
| | | | | | | | | | | | | | | | | | | | 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
* * thread_win32.c (native_stop_timer_thread): fixed commit miss ofusa2011-06-281-1/+1
| | | | | | | 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
* * thread_pthread.c: Stop polling in the timer thread when there areko12011-06-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * thread.c (do_select): Windows: no need to poll if select(2) isusa2011-06-151-0/+28
| | | | | | | | | | | | | | | | | | 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
* * thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.kosaki2011-06-131-0/+9
| | | | | | | | | | * 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
* * thread_pthread.c: rewrite GVL completely.kosaki2011-06-131-2/+2
| | | | | | | | | | | * 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
* * thread_win32.c (native_cond_signal): remove unnecessary rb_bug().kosaki2011-06-131-3/+0
| | | | | | | | 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
* * atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw.nobu2011-06-121-1/+0
| | | | | | * 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
* remove debugging codekosaki2011-05-071-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix win32 native_cond_timedwait() makes SIGSEGV.kosaki2011-05-071-16/+32
| | | | | | | | | | | | | | | | | | * 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
* fix mutex deadlock test hang-up.kosaki2011-05-071-1/+1
| | | | | | | | | * 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
* sleep_cond use monotonic time if possible.kosaki2011-05-061-3/+23
| | | | | | | | | | | | | * 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
* fix win32 compile error.kosaki2011-05-061-0/+2
| | | | | | | | | | * 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
* mutex: deadlock check timeout use monotonic time.kosaki2011-05-061-0/+23
| | | | | | | | | | | | | | | | | * 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
* * thread_pthread.h (rb_thread_cond_t): add clockid field. it'skosaki2011-05-061-1/+1
| | | | | | | | | | | | | 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
* * thread_pthread.c (native_mutex_reinitialize_atfork): removedkosaki2011-05-051-2/+0
| | | | | | | | | 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
* * thread_win32.c, include/ruby/win32.h: add prototypes.nobu2011-04-291-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (native_cond_timedwait): New. r31373 causedkosaki2011-04-291-17/+40
| | | | | | | | | | | | | | 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
* * thread.c (thread_cleanup_func): Moved interrupted_lockkosaki2010-12-201-1/+0
| | | | | | | | | | | | 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
* * thread_win32.c (gvl_release, gvl_init): suppress warnings.nobu2010-11-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread.c, vm_core.h: make gvl_acquire/release/init/destructko12010-11-271-59/+104
| | | | | | | | | | | | | | | | | | | | 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
* * thread_win32.c (w32_error): should get error no only once, becauseusa2010-10-271-2/+3
| | | | | | | | 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
* * Makefile.in (ASFLAGS): needs INCFLAGS.nobu2010-10-261-0/+13
| | | | | | | | | | | | * 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
* * thread_win32.c (w32_error): get English message first, insteadusa2010-10-131-7/+14
| | | | | | | | 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
* * configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf formatnobu2010-10-121-1/+1
| | | | | | specifier if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (w32_wait_events, w32_close_handle): suppress warnings.wanabe2010-09-231-3/+3
| | | | | | see [ruby-core:31932]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_win32.c (native_thread_join): need to wait thread, of course.usa2010-08-021-1/+1
| | | | | | | [ruby-dev:41911] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (Init_BareVM): call Init_native_thread here.akr2010-06-051-1/+1
| | | | | | | | | | | | | | * 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
* * thread_win32.c (w32_wait_events): get GVL before handle interruptwanabe2010-05-051-9/+13
| | | | | | event. [ruby-core:27199], [ruby-core:29698] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e