Граф коммитов

120 Коммитов

Автор SHA1 Сообщение Дата
ko1 fa2c1c75a9 * thread_pthread.c (thread_timer): ignore unknown errno.
(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 10:11:45 +00:00
ko1 d49a61e68f * thread_pthread.c (ping_signal_thread_list, thread_timer):
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 08:27:13 +00:00
ko1 5164677841 * thread_pthread.c (rb_thread_create_timer_thread): allocate
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-30 03:34:16 +00:00
ko1 87dadf3b8c * thread_pthread.c (native_stop_timer_thread): skip to close
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 21:23:40 +00:00
ko1 c22126755c * error.c (rb_async_bug_errno): async-safe bug report function.
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 21:17:29 +00:00
ko1 014a5f3178 * thread_pthread.c (consume_communication_pipe):
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-28 02:53:15 +00:00
naruse 801bac0977 Temporary hack for SIGILL of miniruby on FreeBSD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 18:36:55 +00:00
kosaki 3639736d5d * thread_pthread.c (consume_communication_pipe): don't use C99
style variable length array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 13:10:26 +00:00
kosaki f8cc779680 * thread_pthread.c (consume_communication_pipe): change return
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 13:05:22 +00:00
kosaki ea3da57e12 * thread_pthread.c: s/__gvl_acquire/gvl_acquire_common/ and
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-27 12:18:00 +00:00
naruse c32869dfeb Addtitional fix for previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 02:45:30 +00:00
naruse 657e9e2879 * thread_pthread.c (rb_thread_create_timer_thread):
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 02:43:03 +00:00
ko1 f18cf4f023 * thread_pthread.c (rb_thread_create_timer_thread):
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 00:59:07 +00:00
ko1 d1d5d5e798 * thread_pthread.c: Stop polling in the timer thread when there are
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-27 00:30:41 +00:00
kosaki 2552e428f3 * thread_pthread.c (thread_timer): rename timeout_10ms to
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-20 12:32:35 +00:00
kosaki e623ceb9f9 * thread_pthread.c: remove GVL_DEBUG
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 12:39:01 +00:00
akr afd7e4668f * internal.h: declare more internal functions.
* 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-18 01:54:57 +00:00
ko1 772a281192 * thread_pthread.c, thread_pthread.h: remove unused variables.
(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 19:52:54 +00:00
ko1 1ac74a11c2 * thread_pthread.c (native_thread_create): fix debug message.
(add last newline)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 17:28:54 +00:00
nobu 685444569c * fix for build on solaris 10.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 00:12:55 +00:00
kosaki 82e6d95edc * thread_pthread.c (gvl_yield): fix live lock issue on 1-2 cpus
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-14 16:31:23 +00:00
kosaki afd1a64cd6 * thread.c (rb_thread_schedule_rec): call gvl_yield() unconditionally.
* 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 15:06:30 +00:00
kosaki bcfc22b10e * thread_pthread.c: rewrite GVL completely.
* 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 14:14:53 +00:00
nobu fe244c77b0 * thread_pthread.c (native_cond_timeout): wrap conditinally used label.
* 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-11 01:21:10 +00:00
kosaki 4010bc1e84 * thread_pthread.c (thread_timer): add to care a spurious wakeup.
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-05 12:48:23 +00:00
kosaki 859da83455 * thread_pthread.c (native_sleep): fix 1000times calculation error.
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 13:03:25 +00:00
kosaki dcc1f64cb0 * thread_pthread.c: remove unused macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 08:20:16 +00:00
kosaki 19f52b8740 * thread_pthread.c (native_cond_timedwait): add to care EINTR.
* 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-08 10:46:27 +00:00
kosaki 1816a4a6a9 revert r31474. we cann't call xmalloc under FGLOCK.
Thansk, nagachika-san.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-08 08:52:25 +00:00
kosaki c878761f3b * thread_pthread.c (add_signal_thread_list): use xmalloc instead
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 01:54:58 +00:00
kosaki a3fd4cf507 * thread_pthread.c: cleanup signal_thread_list related ifdef.
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-08 01:50:36 +00:00
nobu 1bd2c78b05 * thread_pthread.c (USE_MONOTONIC_COND): check the availability
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-07 09:28:43 +00:00
kosaki 7ac6b706b4 sleep_cond use monotonic time if possible.
* 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 18:17:14 +00:00
kosaki 604a1e2e22 fix win32 compile error.
* 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 17:50:23 +00:00
kosaki b2ea836ae7 mutex: deadlock check timeout use monotonic time.
* 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 17:39:32 +00:00
kosaki 54b50fbb9c * thread_pthread.c (get_ts): add monotonic clock capability.
* 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 16:56:06 +00:00
kosaki a1cfaf4b1f * thread_pthread.h (rb_thread_cond_t): add clockid field. it's
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-06 16:47:38 +00:00
kosaki b5d612e0df * thread_pthread.c (native_mutex_reinitialize_atfork): removed
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-05-05 13:26:18 +00:00
kosaki ada9870af9 * thread_pthread.c (gvl_init): fix hangup if GVL_SIMPLE_LOCK=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
2011-04-29 15:20:00 +00:00
naruse 63f39fcb40 * random.c (random_rand): remove unused variables.
* 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-04-25 07:56:42 +00:00
nobu 28937bf81f * thread_pthread.c (register_cached_thread_and_wait): move invalid
storage class function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-06 10:59:03 +00:00
kosaki 1ff6a1953c * thread.c (thread_cleanup_func): Moved interrupted_lock
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-12-20 15:20:17 +00:00
kosaki 237edd7a2f * thread_pthread.c (native_thread_destroy): Fixed gvl_cond leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-20 10:25:02 +00:00
ko1 283c36e761 * thread_pthread.c (NATIVE_MUTEX_LOCK_DEBUG): move and use it.
* ChangeLog: fix my timezone.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 13:16:50 +00:00
ko1 e4cf9c59fd * thread_pthread.c: remove pthread_atfork().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 13:00:49 +00:00
ko1 7a4b99129b * thread_pthread.c (native_cond_*): Check return code.
(Some OSs except Linux return error code).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 12:55:43 +00:00
nobu 16d4733ee4 * thread_pthread.c (thread_start_func_1): initialize native thread
data immediately before starting.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 12:46:27 +00:00
nobu 925da00b02 * thread_pthread.c (gvl_release, gvl_init): suppress warnings.
* vm_core.h (rb_vm_gvl_destroy): add prototype.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 05:48:31 +00:00
nobu 079545cd8c * thread_pthread.c (gvl_reinit): register atfork hander only in
the parent process, to get rid of dead lock.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-28 05:46:32 +00:00
ko1 450463d5fb * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
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-11-27 20:15:59 +00:00