aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
Commit message (Collapse)AuthorAgeFilesLines
...
* comment fix.kosaki2011-07-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (thread_start_func_1): suppress an unused variable.nobu2011-07-041-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (get_stack): the return address of get_stacknaruse2011-07-031-3/+9
| | | | | | 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
* * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,ko12011-07-031-0/+12
| | | | | | | | | | | | | | | | | | | | 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_pthread.c (get_stack): pthread_attr_getstack() doesn'tkosaki2011-07-021-8/+13
| | | | | | | | | | | | | 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
* * thread_pthread.c (get_stack): add to a care of gurad page on Mackosaki2011-07-021-7/+9
| | | | | | | | | | | | | 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
* * error.c, thread_pthread.c (WRITE_CONST): suppress warningsnobu2011-06-301-1/+1
| | | | | | `ignoring return value'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (thread_timer): ignore unknown errno.ko12011-06-301-6/+9
| | | | | | | | | (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
* * thread_pthread.c (ping_signal_thread_list, thread_timer):ko12011-06-301-4/+10
| | | | | | | | 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
* * thread_pthread.c (rb_thread_create_timer_thread): allocateko12011-06-301-2/+12
| | | | | | | | | | 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
* * thread_pthread.c (native_stop_timer_thread): skip to closeko12011-06-281-3/+6
| | | | | | | | | 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
* * error.c (rb_async_bug_errno): async-safe bug report function.ko12011-06-281-7/+11
| | | | | | | | | | | | | 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
* * thread_pthread.c (consume_communication_pipe):ko12011-06-281-7/+5
| | | | | | | | | | | 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
* Temporary hack for SIGILL of miniruby on FreeBSD.naruse2011-06-271-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (consume_communication_pipe): don't use C99kosaki2011-06-271-1/+1
| | | | | | | | style variable length array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (consume_communication_pipe): change returnkosaki2011-06-271-3/+2
| | | | | | | | 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
* * thread_pthread.c: s/__gvl_acquire/gvl_acquire_common/ andkosaki2011-06-271-6/+6
| | | | | | | | s/__gvl_release/gvl_release_common/. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Addtitional fix for previous commit.naruse2011-06-271-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (rb_thread_create_timer_thread):naruse2011-06-271-2/+2
| | | | | | 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
* * thread_pthread.c (rb_thread_create_timer_thread):ko12011-06-271-0/+1
| | | | | | | | Fixes missing initialization of oflags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c: Stop polling in the timer thread when there areko12011-06-271-39/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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_pthread.c (thread_timer): rename timeout_10ms tokosaki2011-06-201-5/+5
| | | | | | | | time_quantum. it's no longer 10ms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c: remove GVL_DEBUGkosaki2011-06-181-7/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare more internal functions.akr2011-06-181-2/+0
| | | | | | | | | | | | | | * 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
* * thread_pthread.c, thread_pthread.h: remove unused variables.ko12011-06-161-2/+0
| | | | | | | | (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
* * thread_pthread.c (native_thread_create): fix debug message.ko12011-06-161-1/+1
| | | | | | | | (add last newline) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * fix for build on solaris 10.nobu2011-06-161-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (gvl_yield): fix live lock issue on 1-2 cpuskosaki2011-06-141-6/+17
| | | | | | | | | | 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
* * thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.kosaki2011-06-131-1/+0
| | | | | | | | | | * 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-67/+56
| | | | | | | | | | | * 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_pthread.c (native_cond_timeout): wrap conditinally used label.nobu2011-06-111-1/+2
| | | | | | * 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
* * thread_pthread.c (thread_timer): add to care a spurious wakeup.kosaki2011-06-051-9/+15
| | | | | | | | | | 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
* * thread_pthread.c (native_sleep): fix 1000times calculation error.kosaki2011-06-011-1/+1
| | | | | | | | 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
* * thread_pthread.c: remove unused macro.kosaki2011-06-011-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (native_cond_timedwait): add to care EINTR.kosaki2011-05-081-3/+15
| | | | | | | | * 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
* revert r31474. we cann't call xmalloc under FGLOCK.kosaki2011-05-081-2/+2
| | | | | | | | Thansk, nagachika-san. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (add_signal_thread_list): use xmalloc insteadkosaki2011-05-081-2/+2
| | | | | | | | | | 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
* * thread_pthread.c: cleanup signal_thread_list related ifdef.kosaki2011-05-081-42/+46
| | | | | | | | | 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
* * thread_pthread.c (USE_MONOTONIC_COND): check the availabilitynobu2011-05-071-3/+6
| | | | | | | 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
* sleep_cond use monotonic time if possible.kosaki2011-05-061-33/+41
| | | | | | | | | | | | | * 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-1/+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-36/+45
| | | | | | | | | | | | | | | | | * 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.c (get_ts): add monotonic clock capability.kosaki2011-05-061-3/+22
| | | | | | | | | * 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
* * thread_pthread.h (rb_thread_cond_t): add clockid field. it'skosaki2011-05-061-31/+51
| | | | | | | | | | | | | 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-5/+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_pthread.c (gvl_init): fix hangup if GVL_SIMPLE_LOCK=1.kosaki2011-04-291-1/+1
| | | | | | | | 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
* * random.c (random_rand): remove unused variables.naruse2011-04-251-6/+6
| | | | | | | | | | | | | | * 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
* * thread_pthread.c (register_cached_thread_and_wait): move invalidnobu2011-02-061-1/+4
| | | | | | storage class function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30810 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_pthread.c (native_thread_destroy): Fixed gvl_cond leak.kosaki2010-12-201-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e