summaryrefslogtreecommitdiff
path: root/thread_pthread.c
AgeCommit message (Collapse)Author
2015-10-25* thread_pthread.c: fix compile erros whenodaira
USE_SLEEPY_TIMER_THREAD is disabled. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-06thread_pthread.c: async_bug_fdnobu
* thread_pthread.c (async_bug_fd): show failed file descriptor too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-06thread_pthread.c: async bug messagesnobu
* thread_pthread.c (consume_communication_pipe, CLOSE_INVALIDATE): adjust async bug messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-18* thread_pthread.c (reserve_stack): ensure the memory is reallynaruse
allocated. [Bug #11457] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14thread_pthread.c: suppress a warningnobu
* thread_pthread.c (native_stop_timer_thread): explicit type of old value to suppress a pointer-sign warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14improve handling of timer thread shutdownnormal
Shutting down the timer thread now always closes pipes to free FDs. In fact, we close the write ends of the pipes is done in the main RubyVM to signal the timer thread shutdown. To effectively close pipes, we implement userspace locks via atomics to force the pipe closing thread to wait on any signal handlers which may be waking up. While we're at it, improve robustness during resource exhaustion and allow it to limp along non-fatally if restarting a timer thread fails. This reverts r51268 Note: this change is tested with VM_CHECK_MODE 1 in vm_core.h * process.c (close_unless_reserved): add extra check (dup2_with_divert): remove (redirect_dup2): use dup2 without divert (before_exec_non_async_signal_safe): adjust call + comment (rb_f_exec): stop timer thread for all OSes (rb_exec_without_timer_thread): remove * eval.c (ruby_cleanup): adjust call * thread.c (rb_thread_stop_timer_thread): always close pipes * thread_pthread.c (struct timer_thread_pipe): add writing field, mark owner_process volatile for signal handlers (rb_thread_wakeup_timer_thread_fd): check valid FD (rb_thread_wakeup_timer_thread): set writing flag to prevent close (rb_thread_wakeup_timer_thread_low): ditto (CLOSE_INVALIDATE): new macro (close_invalidate): new function (close_communication_pipe): removed (setup_communication_pipe_internal): make errors non-fatal (setup_communication_pipe): ditto (thread_timer): close reading ends inside timer thread (rb_thread_create_timer_thread): make errors non-fatal (native_stop_timer_thread): close write ends only, always, wait for signal handlers to finish (rb_divert_reserved_fd): remove * thread_win32.c (native_stop_timer_thread): adjust (untested) (rb_divert_reserved_fd): remove * vm_core.h: adjust prototype git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16* process.c (redirect_dup2): when the new FD of dup2() coflictsngoto
with one of the timer thread FDs, the internal FD is diverted. [Bug #11336] [ruby-core:69886] [Bug #11350] [ruby-core:69961] * process.c (dup2_with_divert): new function for the above purpose. * thread_pthread.c (rb_divert_reserved_fd): new function for diverting reserved FD. If the given FD is the same as one of the reserved FDs, the reserved FD number is internally changed. It returns -1 when error. Otherwise, returns 0. It also returns 0 if there is no need to change reserved FD number. * thread_win32.c (rb_divert_reserved_fd): always returns 0 because of no reserved FDs. * internal.h (rb_divert_reserved_fd): prototype declaration. It is Ruby internal use only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15* process.c (redirect_close, parent_redirect_close): should not closengoto
reserved FD. It should be closed in the exec system call due to the O_CLOEXEC or FD_CLOEXEC flag. [Bug #11353] [ruby-core:69977] * process.c (close_unless_reserved): new function to close FD unless it is reserved for internal communication. * thread_pthread.c (rb_reserved_fd_p): should check owner_process pid to avoid false positive in forked child process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-11* configure.in: define SET_THREAD_NAME if it has pthread_set_name_npnaruse
for FreeBSD, and don't define it if both pthread_setname_np and pthread_set_name_np don't exist. * thread_pthread.c (SET_THREAD_NAME): don't define if they don't exist. * thread_pthread.c (native_set_thread_name): run if SET_THREAD_NAME is defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14thread_pthread.c: keep sp safe zonenobu
* thread_pthread.c (reserve_stack): keep sp safe zone to get rid of crash by -fstack-check. [ruby-core:68740] [Bug #11030] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-01thread_pthread.c: use rb_pid_tnobu
* thread_pthread.c (timer_thread_pipe.owner_process): process ID should be pid_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-31thread_pthread.c: Fix intermittent SIGBUS on Linuxnobu
* thread_pthread.c (reserve_stack): fix intermittent SIGBUS on Linux, by reserving the stack virtual address space at process start up so that it will not clash with the heap space. [Fix GH-822] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-28thread.c: micro-optimize thread create/joinnormal
* thread.c (struct join_arg): restructure and make smaller (thread_join_sleep): avoid timeofday() call if forever (thread_join): pass join_arg.delay directly (rb_thread_inspect_msg): remove, inline into rb_thread_inspect (rb_thread_inspect): reduce branching and string creation * thread_pthread.c (native_set_thread_name): create string directly to avoid reparsing. [Misc #10723] This reduces time in benchmark/bm_vm_thread_create_join.rb by a few percent. Minor improvements only: target 0: 2.1.5 (ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]) target 1: trunk (ruby 2.3.0dev (2015-01-16 trunk 49282) [x86_64-linux]) target 2: built (ruby 2.3.0dev (2015-01-16 trunk 49282) [x86_64-linux]) benchmark results: minimum results in each 3 measurements. Execution time (sec) name 2.1.5 trunk built vm_thread_create_join 1.049 1.242 1.138 Speedup ratio: compare with the result of `2.1.5' (greater is better) name trunk built vm_thread_create_join 0.845 0.923 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21* thread_pthread.c (native_set_thread_name): New function toakr
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
2014-09-04* symbian/*: removed Symbian support.hsbt
[Feature #10199][ruby-core:64725] * dln.c: ditto. * include/ruby/defines.h: ditto. * thread_pthread.c: ditto. * vm.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15thread_pthread: prefer rb_nativethread* types/functionsnormal
This will make it easier for us to try alternative mutex/condvar implementations while still using pthreads for thread management. [Feature #10134] * thread_pthread.h: define RB_NATIVETHREAD_LOCK_INIT and RB_NATIVETHREAD_COND_INIT macros * thread_pthread.c (native_mutex_lock, native_mutex_unlock, native_mutex_trylock, native_mutex_initialize, native_mutex_destroy, native_cond_wait): use rb_nativethread_lock_t instead of pthread_mutex_t * thread_pthread.c (native_mutex_debug): make argument type-agnostic to avoid later cast. * thread_pthread.c (register_cached_thread_and_wait): replace PTHREAD_COND_INITIALIZER with RB_NATIVETHREAD_COND_INIT, use native_mutex_{lock,unlock} * thread_pthread.c (use_cached_thread): use native_mutex_{lock,unlock} * thread_pthread.c (native_sleep): use rb_nativethread_lock_t to match th->interrupt_lock, use native_mutex_{lock,unlock} * thread_pthread.c (timer_thread_lock): use rb_nativethread_lock_t type git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-11thread.c: fix for non-scalar pthread_tnobu
* configure.in (rb_cv_scalar_pthread_t): pthread_t is not required to be a scalar type. * thread.c (fill_thread_id_string, thread_id_str): dump pthread_t in hexadecimal form if it is not a scalar type, assume it can be represented in a pointer form otherwise. based on the patch by Rei Odaira at [ruby-core:62867]. [ruby-core:62857] [Bug #9884] * thread_pthread.c (Init_native_thread, thread_start_func_1), (native_thread_create): set thread_id_str if needed. * vm_core.h (rb_thread_t): add thread_id_string if needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-11thread_pthread.c: timer thread flagnobu
* 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
2014-05-10thread_pthread.c: variable for errnonobu
* thread_pthread.c (rb_thread_wakeup_timer_thread_fd): use a local variable for errno. * thread_pthread.c (consume_communication_pipe): ditto. add EWOULDBLOCK case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10thread_pthread.c: timer_thread_pipe structnobu
* thread_pthread.c (timer_thread_pipe): aggregate timer thread pipe stuff into a struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10thread_pthread.c: compare with pthread_equalnobu
* thread_pthread.c (ubf_select): compare thread_id with pthread_equal() but not directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-10thread_pthread.c: variable for errnonobu
* thread_pthread.c (timer_thread_sleep): use a local variable for errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-09thread_*.c: constifynobu
* 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
2014-02-27configure.in: define SET_THREAD_NAMEnobu
* configure.in (SET_THREAD_NAME): define according to pthread_setname_np variations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-13configure.in: use pthread_setname_np only if availablenobu
* configure.in: check if pthread_setname_np is available. * thread_pthread.c: pthread_setname_np is not available on old Darwins. [ruby-core:60524] [Bug #9492] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28thread_pthread.c: use get_stacknobu
* thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p): place get_stack above others to get stack boundary information. [ruby-core:60113] [Bug #9454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28* thread_pthread.c: rlimit is only available on Linux.naruse
At least r44712 breaks FreeBSD. [ruby-core:60113] [Bug #9454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28vm_core.h: rb_thread_struct::machinenobu
* 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
2014-01-27thread_pthread.c: cast to size_tnobu
* thread_pthread.c (ruby_stack_overflowed_p): range of rlim_cur may be larger than size_t. [ruby-core:60113] [Bug #9454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-27thread_pthread.c: get current main thread stack sizenobu
* thread_pthread.c: get current main thread stack size, which may be expanded than allocated size at initialization, by rlimit(). [ruby-core:60113] [Bug #9454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21thread_pthread.c: fix for dynamic PTHREAD_STACK_MINnobu
* thread_pthread.c (rb_thread_create_timer_thread): fix for platforms where PTHREAD_STACK_MIN is a dynamic value and not a compile-time constant. [ruby-dev:47911] [Bug #9436] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21* thread_pthread.c (rb_thread_create_timer_thread): fix missing paren.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21thread_pthread.c: expand timer thread stack sizenobu
* thread_pthread.c (rb_thread_create_timer_thread): expand timer thread stack size to get rid of segfault on FreeBSD/powerpc64. based on the patch by Steve Wills at [ruby-core:59923]. [ruby-core:56590] [Bug #8783] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21thread_pthread.c: timer thread stack sizenobu
* thread_pthread.c (rb_thread_create_timer_thread): define the stack size for timer thread at compile time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-18thread_pthread.c: use get_main_stack properlynobu
* thread_pthread.c (ruby_init_stack): set stack_start properly by get_main_stack() if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-16* thread_pthread.c (rb_thread_create_timer_thread): Show errorakr
message instead of error number. * cont.c (fiber_machine_stack_alloc): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-03thread_pthread.c: set thread namenobu
* thread_pthread.c (thread_timer): set timer thread name on OSX too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03thread_pthread.c: fix compile error on HP-UXnobu
* thread_pthread.c (sys/dyntune.h): for gettune(). * thread_pthread.c (hpux_attr_getstackaddr): fix missing *. [ruby-core:56983] [Feature #8793] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30thread_pthread.c: fill stack info by creator threadnobu
* thread_pthread.c (native_thread_init_stack): wait the creator thread to fill machine stack info, if get_stack_of() is available. * thread_pthread.c (native_thread_create): fill the created thread stack info after starting, if get_stack_of() is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30thread_pthread.c: define attr only if usednobu
* thread_pthread.c (native_thread_create): define attr only if it is used, and merge pthread_create() calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30thread_pthread.c: get_main_stacknobu
* thread_pthread.c (get_main_stack): separate function to get stack of main thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-30thread_pthread.c: fix vps_pagesizenobu
* thread_pthread.c (hpux_attr_getstackaddr): vps_pagesize is defaulted to 16 and in Kbytes. [ruby-core:56863] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28thread_pthread.c: get_stack on HP-UXnobu
* thread_pthread.c (hpux_attr_getstackaddr): basic support for the get_stack() under HP-UX. based on the patch by michal@rokos.cz (Michal Rokos) at [ruby-core:56645]. [Feature #8793] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28thread_pthread.c: dup codenobu
* thread_pthread.c (get_stack): merge duplicated code split by ifdef. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-28thread_pthread.c: simplifynobu
* thread_pthread.c (register_cached_thread_and_wait): simplify and reduce branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23* thread_(pthread|win32).h: rename rb_thread_cond_t toko1
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
2013-07-23* thread_native.h: add rb_nativethread_self() which returnsko1
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
2013-07-23* thread_pthread.h, thread_win32.h: rename rb_thread_id_t toko1
rb_nativethread_id_t. * thread_pthread.c, vm_core.h: use rb_nativethread_id_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23* thread_native.h: added.ko1
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
2013-06-07* internal.h (numberof): Gathered from various files.akr
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c, load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c, error.c, ruby.c: Remove the definitions of numberof. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e