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

375 Коммитов

Автор SHA1 Сообщение Дата
nobu 6b1bae9641 * thread.c (rb_mutex_unlock_th): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13 09:29:13 +00:00
nobu 8032371462 * thread.c (rb_barrier_waiting): fix potential overflows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13 09:25:54 +00:00
ayumin 966d1f8962 * thread.c: changed documentation for "thread-local" variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-03 07:01:15 +00:00
naruse 82ab1e189b * thread.c (rb_barrier_waiting): save the number of waiting threads
in RBASIC()->flags. [ruby-dev:45002] [Bug #5768]

* thread.c (rb_barrier_wait): increment and decrement around
  rb_mutex_lock, and use rb_barrier_waiting().

* thread.c (rb_barrier_release): use rb_barrier_waiting().

* thread.c (rb_barrier_destroy): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-30 22:25:16 +00:00
nobu 50c1985555 * load.c (load_unlock): release loading barrier and then remove it
from loading_table if it is not in-use.  [Bug #5754]
* thread.c (rb_barrier_release, rb_barrier_destroy): return
  whether any other threads are waiting on it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14 03:20:02 +00:00
nobu f2fff83e96 * load.c (load_lock): delete the loading barrier if it has been
destroyed.
* thread.c (rb_barrier_wait): return nil for recursive lock
  instead of false, to distinguish it from destroyed barrier.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14 01:20:11 +00:00
nobu ab6c8910f4 * load.c (load_unlock): all threads requiring one file should
share same loading barrier, so it must be kept alive while those
  are waiting on it.  [ruby-core:41618] [Bug #5754]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-13 07:13:31 +00:00
akr 3d25acdccc * io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: use
__linux__ macro for consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15 11:09:47 +00:00
naruse b10c3136b0 * thread.c (do_select): fix cast, tv_sec is time_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 02:06:49 +00:00
nobu ac46d76ce8 * thread.c (rb_fd_rcopy): suppress warnings on mingw32.
* win32/win32.c (overlapped_socket_io, recvmsg, sendmsg, dupfd):
  ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 13:50:55 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
kosaki 1bdf1a5c6f * thread_pthread.c: make native_fd_select().
* thread.c (do_select): remove #ifdef _WIN32. Instead, use
  native_fd_select() always.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-27 00:59:04 +00:00
kosaki 2cc5eeaf6c * thread.c (do_select): remove cygwin specific hack. It's layer
violation and too large hack.
* thread.c (cmp_tv, subtract_tv): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-27 00:50:29 +00:00
kosaki d24e1dac2b * thread.c (rb_fd_rcopy): added an argument guard.
Patch by NAKAMURA Usaku. [Bug #5306] [ruby-core:39435]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-14 02:44:57 +00:00
kosaki 2c9375ba69 * thread.c (rb_thread_select): fix to ignore an argument
modification of rb_thread_fd_select().
  based on a patch by Eric Wong. [Bug #5306] [ruby-core:39435]
* thread.c (rb_fd_rcopy): New. for reverse fd copy.

* test/-ext-/old_thread_select/test_old_thread_select.rb
(test_old_select_false_positive): test for bug5306.

* ext/-test-/old_thread_select/old_thread_select.c (fdset2array):
  New. convert fdsets to array.
* ext/-test-/old_thread_select/old_thread_select.c (old_thread_select):
  return 'read', 'write', 'except' argument of rb_thread_select()
  to ruby script.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-12 11:36:06 +00:00
nobu 61b062ba6d * thread.c (rb_thread_select): fix a typo to initialize efds
properly.  [Bug #5299] [ruby-core:39380]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-09 01:22:06 +00:00
usa a34f81561d * thread.c (rb_thread_select): critical typo in r33117.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-30 15:49:55 +00:00
usa ee7d523631 * win32/win32.c, include/ruby/intern.h (rb_w32_fd_copy): implement
for rb_thread_select() in thread.c.  the use of rb_fd_copy() is
  introduced in r33117.
  [Bug #5229] [ruby-core:39102]

* thread.c (rb_thread_select): must call rb_fd_init() before using
  rb_fdset_t.  see the implementations of rb_fd_init()s if you want to
  know the reason.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-30 15:04:11 +00:00
kosaki 0cebfad20a * thread.c (rb_thread_select): rewrite by using
rb_thread_fd_select(). old one is EINTR unsafe.
  Patch by Eric Wong. [Bug #5229] [ruby-core:39102]

* test/-ext-/old_thread_select/test_old_thread_select.rb:
  a testcase for rb_thread_select().
* ext/-test-/old_thread_select/old_thread_select.c: ditto.
* ext/-test-/old_thread_select/depend: ditto.
* ext/-test-/old_thread_select/extconf.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-30 00:33:05 +00:00
mame 54163e2b52 * thread.c (update_coverage): skip coverage count up if the current
line is out of the way.  rb_sourceline() is unreliable when source
  code is big.  [ruby-dev:44413]

* test/coverage/test_coverage.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-23 15:44:26 +00:00
mrkn 248d589b55 * thread.c: add a description for the behavior of select(2) on
Mac OS X 10.7 (Lion).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-19 04:17:04 +00:00
mame 9752864b88 * thread.c (set_trace_func, thread_set_trace_func_m): reset tracing
state when set_trace_func hook is removed.  This is workaround patch
  to force to reset tracing state that is broken by continuation call.
  a patch from James M. Lawrence.  [Feature #4347] [ruby-core:34998]

* test/ruby/test_continuation.rb (class TestContinuation): add a test
  for above.  a patch from James M. Lawrence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-21 11:09:52 +00:00
kosaki b9a13f4962 * thread_pthread.c (mutex_debug): use exit(EXIT_FAILURE) instad of
exit(1).
* thread_pthread.c (add_signal_thread_list): ditto.
* thread.c (rb_thread_call_with_gvl): ditto.
* util.c (Bug): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 08:29:46 +00:00
kosaki a119b9d146 * vm_core.h (typedef struct rb_vm_struct): create a new
'inhibit_thread_createion' field.
* thread.c (rb_thread_terminate_all): set inhibit_thread_creation.
* thread.c (thread_s_new): don't permit to create new thread
  if the VM is under destruction. Otherwise evil finalizer code
  can make SEGV. [Bug #4992][ruby-core:37858]

* bootstraptest/test_objectspace.rb: new test for this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 07:46:00 +00:00
nobu 837e73ab6d * thread.c (cmp_tv, subtract_tv): no longer used on Win32.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 07:01:12 +00:00
kosaki 554a33d838 * thread.c (rb_mutex_unlock_all): folded into
rb_threadptr_unlock_all_locking_mutexes.
* thread.c (rb_threadptr_unlock_all_locking_mutexes) ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 04:50:25 +00:00
kosaki 8741274529 * thread.c (thread_unlock_all_locking_mutexes): rename to
rb_threadptr_unlock_all_locking_mutexes and remove static.
* vm_core.h: add rb_threadptr_unlock_all_locking_mutexes declaration.
* thread.c (thread_start_func_2): adjust the above rename.

* eval.c (ruby_cleanup): call rb_threadptr_unlock_all_locking_mutexes
  again after finalizer. [Bug #4988] [ruby-dev:44049]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 04:40:01 +00:00
kosaki c05fd75bef * thread.c (do_select): fix memory leak.
Patch by Eric Wong. Thank you! [Bug #4953] [ruby-core:37702]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-01 02:08:48 +00:00
ko1 fa4514e4fe * thread.c (rb_threadptr_check_signal): only wake up main thread.
* thread.c (rb_threadptr_execute_interrupts_common): check signal
  deliverly if it is main thread.
  fixes [ruby-dev:44005] [Ruby 1.9 - Bug #4950]
* bootstraptest/test_fork.rb: add a test for above.
* signal.c (rb_get_next_signal): skip if signal_buff is empty.
  (check signal_buff.size first)
* vm_core.h: remove unused variable rb_thread_t::exec_signal.
* thread.c (rb_thread_check_trap_pending): check
  rb_signal_buff_size() because rb_thread_t::exec_signal
  is no longer available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 22:29:34 +00:00
ko1 065fe8b7a4 * vm_insnhelper.c (vm_call_bmethod): fix to hook call/return event
for methods defined by define_method().
* thread.c (call_trace_proc): Fix to skip if class is not given (0).
  Note that ID and Class object are passed for call/return event
  if the called method was defined by define_method().
  If you are author of tracer/profiler/debugger, this may be an
  important change.  You should check passed class as zero or
  non-zero instead of checking the event type.
* test/ruby/test_settracefunc.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 13:34:53 +00:00
drbrain be9d096cc9 * thread.c (ruby_thread_s_pass): Fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 21:23:36 +00:00
kosaki 6f1ce28d62 * thread.c (rb_threadptr_execute_interrupts_common): remove
meaningless native_thread_yield(). It never close a race.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 17:55:03 +00:00
kosaki c90ff68d32 * thread.c (rb_thread_schedule_limits): minor optimization.
eliminate machine context saving when running time is enough small.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 17:43:58 +00:00
kosaki 5e15194561 * thread.c (rb_thread_schedule_rec): move interrupt_flag check to
rb_thread_schedule().
  And also rename to rb_thead_schedule_limits() and remove
  sched_depth argument. It's no longer called recursive.
* thread.c (rb_thread_schedule): add to check interrupt_flag as
  above explained.

* thread.c (rb_threadptr_execute_interrupts_rec): rename to
  rb_threadptr_execute_interrupts_common() and remove sched_depth
  argument. It's no longer called recursive.

* thread.c (rb_thread_sleep): adapt the renaming.
* thread.c (rb_threadptr_execute_interrupts): ditto.
* thread.c (rb_thread_execute_interrupts): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 17:36:00 +00:00
kosaki ed0876f66d * thread.c (thread_s_pass): change RDoc description and remove
a sample code. The actual implementaion never behave as explained by
  an example. It's a documentation bug.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 16:34:51 +00:00
kosaki 3a9117011f * thread.c (rb_thread_stop): change RDoc sample code. The old
example is buggy and may cause deadlock. The patch is
  suggested by Heesob Park <phasis@gmail.com>. Thank you!
  [Bug #3606][ruby-core:31454]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 15:55:44 +00:00
kosaki b3ad7b9ea1 * thread.c (rb_thread_wakeup): change RDoc sample code. The old
example is buggy and may not display anything by a race.
  The patch is suggested by Heesob Parrk <phasis@gmail.com>.
  Thank you! [Bug #3606][ruby-core:31454]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 15:51:54 +00:00
kosaki b07b51f7fc * thread.c (rb_thread_run): change RDoc. The old example is buggy
and may cause deadlock. The patch is suggested by Heesob Park
  <phasis@gmail.com>. Thank you! [Bug #3606][ruby-core:31454]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 15:47:24 +00:00
nahi 4a42dda482 * thread.c (rb_thread_local_aref): RDoc fix. Thread#[] example
had a race. See #4480.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 20:09:59 +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
nagachika fb72e453f9 * thread.c (sleep_forever): now Kernel#sleep don't wakeup by
signal handler execution. [Bug #4072]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-25 14:28:56 +00:00
nagachika 1a196574c4 * thread.c (rb_threadptr_check_signal): remove unnecessary th->status
backup. fix race condition which may results unexpected main thread's
  status transition. see #4072

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-25 14:21:16 +00:00
akr 5ed8c08aa0 * eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don't
declare internal functions.

* internal.h, vm_core.h: declare internal functions.

* array.c: include internal.h.

* common.mk: update dependency for array.o.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 08:26:19 +00:00
akr 7da3ea811e * method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
  thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
  declare internal functions.

  Note that rb_method_entry_eq() is defined in vm_method.c but
  there was a declaration in proc.c with different const-ness.
  Now it is declared in method.h with same const-ness to the
  definition.

* object.c (rb_mod_module_exec): don't declare functions declared in
  include/ruby/intern.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 03:49:33 +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
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
kosaki 3c23284734 * thread.c (rb_thread_schedule_rec): fix {UN,}LIKELY macro misuse.
* gc.c (rb_newobj): ditto.
* vm_insnhelper.c (vm_method_search): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 14:42:02 +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
usa a8bdd28d10 * thread.c (do_select): Windows: no need to poll if select(2) is
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
2011-06-15 18:04:13 +00:00
kosaki 2ebd80d115 * thread.c: remove BLOCKING_REGION_CORE() macro. It's no longer used
since r32021.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-15 14:13:01 +00:00