summaryrefslogtreecommitdiff
path: root/thread_pthread.c
AgeCommit message (Collapse)Author
2011-07-04* thread_pthread.c (native_sleep): cut the waiting time up tomame
100,000,000 because Solaris cond_timedwait() return EINVAL if an argument is greater than current_time + 100,000,000. This is considered as a kind of spurious wakeup. The caller to native_sleep should care about spurious wakeup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04* thread_pthread.c (get_stack): For NetBSD/FreeBSD, usekosaki
pthread_attr_getstack() if possible. and, remove an assumption of stack growing direction. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04comment fix.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-04* thread_pthread.c (thread_start_func_1): suppress an unused variable.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-03* thread_pthread.c (get_stack): the return address of get_stacknaruse
must be the highest address of the current thread's stack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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-07-02* thread_pthread.c (get_stack): pthread_attr_getstack() doesn'tkosaki
return stack start addres, but stack base address. Thus, we need to add stack size for getting stack start address. And, we don't have to decrease guard size twice. * thread_pthread.c (thread_start_func_1): don't use inaccurate stack start guess if native_thread_init_stack() can be used. [Bug #1813] [ruby-core:24540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-02* thread_pthread.c (get_stack): add to a care of gurad page on Mackosaki
OS X. [Bug #1813] [ruby-core:24540] * signal.c (ruby_signal): SIGBUS use alternative stack too. * signal.c (sigbus): On Mac, thread stack overflow makes SIGBUS instead of SIGSEGV. thus, added stackoverflow check. * signal.c (default_handler): get rid of compilation warning. * signal.c (Init_signal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30* error.c, thread_pthread.c (WRITE_CONST): suppress warningsnobu
`ignoring return value'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30* thread_pthread.c (thread_timer): ignore unknown errno.ko1
(we observed that select(2) was canceled by errno=514 on boron == Linux/Xen environment) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30* thread_pthread.c (ping_signal_thread_list, thread_timer):ko1
fix to keep polling state if there are any ping-tasks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30* thread_pthread.c (rb_thread_create_timer_thread): allocateko1
machine stack for the timer thread at least 12KB. FreeBSD 8.2 AMD64 causes machine stack overflow (SIGSEGV) only with PTHREAD_STACK_MIN (maybe defined as 2KB). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28* thread_pthread.c (native_stop_timer_thread): skip to closeko1
communication pipe to avoid timing bug (process termination timing). The communication pipe will closed by OS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28* error.c (rb_async_bug_errno): async-safe bug report function.ko1
In timer thread, signal handler shoul use it. The patch is contributed by Eric Wong <normalperson@yhbt.net>. Refs: [ruby-core:37644] and [ruby-core:37647] * thread_pthread.c: use rb_async_bug_errno(). And replace all fprintf() to write(). * internal.h (rb_async_bug_errno): add decl. of above func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-28* thread_pthread.c (consume_communication_pipe):ko1
Make "buff" as static. (Maybe) "buff" can be shared between any caller (any threads) because no one use the read values. And remove const value "buff_size", and define CCP_READ_BUFF_SIZE macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27Temporary hack for SIGILL of miniruby on FreeBSD.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (consume_communication_pipe): don't use C99kosaki
style variable length array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (consume_communication_pipe): change returnkosaki
type to void. caller doesn't use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c: s/__gvl_acquire/gvl_acquire_common/ andkosaki
s/__gvl_release/gvl_release_common/. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27Addtitional fix for previous commit.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (rb_thread_create_timer_thread):naruse
the type of retrun value of write(2) is ssize_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* thread_pthread.c (rb_thread_create_timer_thread):ko1
Fixes missing initialization of oflags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32245 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-20* thread_pthread.c (thread_timer): rename timeout_10ms tokosaki
time_quantum. it's no longer 10ms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* thread_pthread.c: remove GVL_DEBUGkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* internal.h: declare more internal functions.akr
* iseq.h (rb_method_get_iseq): declared. * compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c, ruby.c, time.c, util.c, vm.c: don't declare internal functions. * eval.c, parse.y, thread_pthread.c: non-existing function declarations removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16* thread_pthread.c, thread_pthread.h: remove unused variables.ko1
(native_thread_data_t::gvl_cond, native_thread_data_t::gvl_next) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16* thread_pthread.c (native_thread_create): fix debug message.ko1
(add last newline) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16* fix for build on solaris 10.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14* thread_pthread.c (gvl_yield): fix live lock issue on 1-2 cpuskosaki
system. It's additional fix for r32021. * thread_pthread.c (gvl_init): add switch_wait_cond. * thread_pthread.h (typedef struct rb_global_vm_lock_struct): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32091 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-11* thread_pthread.c (native_cond_timeout): wrap conditinally used label.nobu
* thread_pthread.c (native_sleep): remove unused variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-05* thread_pthread.c (thread_timer): add to care a spurious wakeup.kosaki
When native_cond_timedwait() return 0 by spurious wakeup, we don't have to neither 1) call timer_thread_function and 2) exit the timer thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01* thread_pthread.c (native_sleep): fix 1000times calculation error.kosaki
this is a regression since r31457. [Bug #4808] [ruby-dev:43606] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01* thread_pthread.c: remove unused macro.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c (native_cond_timedwait): add to care EINTR.kosaki
* thread_pthread.c (thread_timer): remove EINTR check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08revert r31474. we cann't call xmalloc under FGLOCK.kosaki
Thansk, nagachika-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c (add_signal_thread_list): use xmalloc insteadkosaki
of malloc. * thread_pthread.c (remove_signal_thread_list): use xfree instead of free. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08* thread_pthread.c: cleanup signal_thread_list related ifdef.kosaki
1) we don't have to use #ifdef FOO-PLATFORM directly 2) About half #ifdef didn't care symbian properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-07* thread_pthread.c (USE_MONOTONIC_COND): check the availabilitynobu
more strictly. * thread_pthread.h (rb_thread_cond_t): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31462 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.c (get_ts): add monotonic clock capability.kosaki
* thread_pthread.c (rb_thread_create_timer_thread): use monotonic clock if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31453 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_pthread.c (gvl_init): fix hangup if GVL_SIMPLE_LOCK=1.kosaki
We don't have to call mutex_unlock() before initialize it! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-25* random.c (random_rand): remove unused variables.naruse
* struct.c (rb_struct_define_without_accessor): ditto. * strftime.c (rb_strftime_with_timespec): ditto. * sprintf.c: ditto. * time.c (time_asctime): remove useless GetTimeval(). * thread_pthread.c: cast to (void *) for %p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-06* thread_pthread.c (register_cached_thread_and_wait): move invalidnobu
storage class function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e