summaryrefslogtreecommitdiff
path: root/thread.c
AgeCommit message (Collapse)Author
2012-12-05* thread.c (rb_uninterruptible): helper function for providingkosaki
temporary async_interrupt_timing(Object => :defer) * io.c (rb_f_p): use rb_uninterruptible. * io.c (rb_f_p_internal): helper function for rb_f_p(). * io.c (struct rb_f_p_arg): new struct for rb_f_p_internal. * test/ruby/test_thread.rb (test_async_interrupt_and_p): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05 * thread.c (rb_thread_s_async_interrupt_timing): have to check ints before ↵tarui
jumpping out. * test/ruby/test_thread.rb (test_async_interrupt_with_return): add test rescue has to catch a queued async exception at the time of return. * test/ruby/test_thread.rb (test_async_interrupt_with_break): add test rescue has to catch a queued async exception at the time of break. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 * vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): check async queue everytime.tarui
* thread.c (sleep_forever): check RUBY_VM_CHECK_INTS_BLOCKING first. * thread.c (sleep_timeval): ditto. * test/ruby/test_thread.rb (test_async_interrupt_blocking): add a test exceptions are correctly defared and raised on :on_blocking context. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04supress warningkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04supress warningkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04* thread.c (rb_mutex_owned_p): new method that return currentkosaki
thread have the target mutex or not. [Feature #7505] [ruby-dev:46697] * test/ruby/test_thread.rb (test_mutex_owned, test_mutex_owned2): test for the above. * NEWS: new for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT, rb_gc_save_machine_context): tarui
extract rb_gc_save_machine_context to RB_GC_SAVE_MACHINE_CONTEXT. NOTE: machine_regs and machine_stack_end must be set in current scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02revert r38141 for stack problemtarui
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT, rb_gc_save_machine_context):tarui
Don't set machine_regs and machine_stack_end with a different scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* thread.c (Thread.async_interrupt_timing): fix RDoc.ko1
:never is not used any more. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* thread.c (rb_threadptr_interrupt_mask, async_interrupt_timing_func):kosaki
merge into them into rb_thread_s_async_interrupt_timing. * thread.c (rb_thread_s_async_interrupt_timing): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* thread.c (rb_threadptr_interrupt_mask): add argument check.kosaki
* thread.c (async_interrupt_timing_arg_check_i): helper function for the above. * test/ruby/test_thread.rb (test_async_interrupt_timing_invalid_argument): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* vm_core.h (rb_vm_struct): add thread_destruct_lock field.kosaki
* thread.c (Init_Thread): ditto. * thread.c (rb_vm_gvl_destroy): ditto. * thread.c (thread_start_func_2): make sure vm->running_thread don't point to dead thread. * thread.c (timer_thread_function): close a race against thead destruction. [Bug #4911][ruby-dev:43859] * vm_core.h (rb_thread_set_current): reset running time of current thread instead of previous thread. We no longer assume previous running thread still live. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30revert r35486 (add rb_thread_t#yeiling field). because it doesn't helpkosaki
to close a race. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* thread.c: TracePoint#self returns invoking/exitting thread objectko1
at thread_begin/end event. * test/ruby/test_settracefunc.rb: fix test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* thread.c: rename Thread.control_interruptko1
to Thread.async_interrupt_timing. The option name `:never' is also changed to `:defer'. [ruby-core:50375] [ruby-trunk - Feature #6762] * thread.c: remove Thread.check_interrupt. This method is difficult to understand by name. * thraed.c: add Thread.async_interrupted?. This method check any defered async interrupts. * test/ruby/test_thread.rb: change tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* thread.c (rb_thread_interrupted): avoid warning ofko1
implicit conversion. * thread.c (rb_threadptr_execute_interrupts): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 [EXPERIMENTAL: NEED DISCUSS]ko1
* vm_trace.c: add events * :thread_begin - hook at thread beggining. * :thead_end - hook at thread ending. * :b_call - hook at block enter. * :b_return - hook at block leave. This change slow down block invocation. Please try and give us feedback until 2.0 code freeze. * include/ruby/ruby.h: ditto. * compile.c (rb_iseq_compile_node): ditto. * insns.def: ditto. * thread.c: ditto. * vm.c: ditto. * include/ruby/debug.h: add a comment. * test/ruby/test_settracefunc.rb: add a tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29Revert r37956: thread.c (thread_start_func_2): small cleanups.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* thread.c (thread_start_func_2): remove unused code. Whenkosaki
th->safe_level == 4, th->errinfo never be thrown. So, to create new exception makes no sense. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29Revert r37953: thread.c (thread_start_func_2): remove unused code. securitynaruse
This sticks at bootstraptest/test_fork.rb:24 on FreeBSD and darwin. http://fb.rubyci.org/~chkbuild/ruby-trunk/log/20121128T230302Z.log.html.gz http://a.mrkn.jp/~mrkn/chkbuild/sl/ruby-trunk-m64-gcc42-o0/log/20121128T235908Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* thread.c (do_select): suppress warning (uninitialized value warning)naruse
with UNINITIALIZED_VAR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_start_func_2): small cleanups.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_start_func_2): remove unused code.kosaki
this function never be used for main thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_start_func_2): remove unused code.kosaki
errinfo = th->errinfo; and errinfo = rb_errinfo(); are the same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_start_func_2): remove unused code. securitykosaki
level is checked before rb_eSecurityError raises. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (rb_mutex_sleep): fix to allow spurious wakeup.ko1
* NEWS: write about spurious wakeup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* include/ruby/thread.h (rb_thread_call_without_gvl2): changeko1
meaning of function. This function is called with same parameters of `rb_thread_call_without_gvl()'. However, if interrupts are detected, when return immediately. * thread.c: implement `rb_thread_call_without_gvl2()'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 * thread.c (thread_join_sleep): check spurious wakeup by itself fortarui
corresponding status change in trap context. * vm_core.h (struct rb_thread_struct): add rb_thread_list_t and use as join_list for reentry by trap context. * thread.c (thread_start_func_2): ditto. * thread.c (remove_from_join_list): ditto. * thread.c (rb_thread_atfork): ditto. * thread.c (thread_join): ditto. & remove trap handler check. * thread.c (sleep_forever): add argument : spurious_check. * thread.c (sleep_timeval): ditto. * thread.c (rb_thread_sleep_forever): set spurious_check. * thread.c (rb_thread_sleep_deadly): ditto. * thread.c (sleep_for_polling): ditto. * thread.c (rb_thread_wait_for): ditto. * thread.c (sleep_wait_for_interrupt): bypass spurious_check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* vm_core.h (enum rb_thread_status): remove THREAD_TO_KILLkosaki
* vm_core.h (struct rb_thread_struct): add to_kill field * thread.c (terminate_i): convert THREAD_TO_KILL to to_kill. * thread.c (rb_threadptr_to_kill): ditto. * thread.c (rb_thread_kill): ditto. * thread.c (rb_thread_wakeup_alive): ditto. * thread.c (thread_list_i): ditto. * thread.c (static const char): ditto. * thread.c (thread_status_name): ditto. * thread.c (rb_thread_status): ditto. * thread.c (rb_thread_inspect): ditto. * vm_backtrace.c (thread_backtrace_to_ary): ditto. * thread.c (rb_threadptr_execute_interrupts): fix thread status overwritten issue. [Bug #7450] [ruby-core:50249] * test/ruby/test_thread.rb (test_hread_status_raise_after_kill): test for the above. * test/ruby/test_thread.rb (test_thread_status_in_trap): test for thread status in trap. * test/ruby/test_thread.rb (test_status_and_stop_p): remove Thread.control_interrupt unsafe test. Thread#kill no longer changes thread status. Instead of, Thread#kill receiver changes their own status when receiving kill signal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (struct rb_mutex_struct): add allow_trap field.kosaki
* internal.h (rb_mutex_allow_trap): added. * thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap. * thread.c (mutex_sleep): remove trap check because it uses rb_mutex_lock and rb_mutex_unlock internally. * thread.c (rb_mutex_allow_trap): new helper function for the above. * io.c (io_binwrite): mark fptr->write_lock as writable in trap. * test/ruby/test_signal.rb (test_trap_puts): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (rb_mutex_lock): moved trap context check fromkosaki
rb_mutex_trylock because try_lock have no change to make a deadlock. * thread.c (rb_mutex_trylock): ditto. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_s_new): uses main_thread->status instead ofkosaki
th->inhibit_thread_creation for preventing thread creation. * vm_core.h (rb_vm_struct): remove inhibit_thread_creation field. * thread.c (rb_thread_terminate_all): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (thread_join): A trap handler check was moved fromkosaki
thread_join_m because Thread#value should be raised an exception too. * thread.c (thread_join_m): remove trap handler check. * test/ruby/test_thread.rb (test_thread_join_in_trap): add test for thread#value. * NEWS: documentation fix for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* thread.c (rb_thread_terminate_all): retry broadcast only whenko1
an exception is raised. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* thread.c (rb_thread_terminate_all): broadcast terminate eventko1
not only an interrupt exception but any exceptions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* thread.c (rb_thread_terminate_all): suppress a warning.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* thread.c (thread_join): raises ThreadError if target theradkosaki
is a main thread. * test/ruby/test_thread.rb (test_thread_join_main_thread): test for the above. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* thread.c (thread_join): raises ThreadError if target threadkosaki
is a current thread. * test/ruby/test_thread.rb (test_thread_join_current): test for the above. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* thread.c (rb_thread_terminate_all): broadcast eTerminateSignalkosaki
again when Ctrl-C was pressed. [Feature #1952] [ruby-dev:39107] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* thread.c (rb_thread_terminate_all): add RUBY_VM_CHECK_INTS_BLOCKING().kosaki
Otherwise the loop in this function behave as busy loop because native_sleep() return immediately when RUBY_VM_INTERRUPTED() is true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* thread.c (rb_mutex_trylock, rb_mutex_unlock, mutex_sleep):kosaki
raises ThreadError if called from trap handler as Thread#join. * NEWS: news fot the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* thread.c (rb_thread_terminate_all): use native_sleep() insteadkosaki
of rb_thread_schedule(). Otherwise, it consume 100% cpu meaninglessly. [Bug #5368] [ruby-dev:44546] * thread.c (thread_start_func_2): last sub-thread wakes up main thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT)kosaki
(RUBY_VM_SET_FINALIZER_INTERRUPT, RUBY_VM_SET_TRAP_INTERRUPT) (RUBY_VM_INTERRUPTED): use enum symbol instead of immediate value. * thread.c (thread_join_m, rb_threadptr_execute_interrupts): ditto. * signal.c (signal_exec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* thread.c (thread_join_m): use th->interrupt_mask instead ofkosaki
th->in_trap. * vm_core.h (struct rb_thread_struct): remove in_trap member. * signal.c (signal_exec): ditto. * thread.c (thread_create_core): ditto. * thread.c (Init_Thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* ruby_atomic.h (ATOMIC_CAS): new macro for compare-and-exchange.kosaki
* vm_core.h (struct rb_thread_struct): add interrupt_mask member. * thread.c (thread_create_core, Init_Thread): initialize th->thread_mask. * vm_core.h (RUBY_VM_INTERRUPTED_ANY): new macro for avoiding bare th->interrupt_flag. * vm_core.h (RUBY_VM_INTERRUPTED, RUBY_VM_INTERRUPTED): check th->interrupt_mask. * thread.c (set_unblock_function, rb_thread_schedule): replace th->interrupt_flag with RUBY_VM_INTERRUPTED_ANY() * signal.c (signal_exec): set up thread->interrupt_mask for preventing recursive trap handler. * vm_core.h (RUBY_VM_CHECK_INTS, RUBY_VM_CHECK_INTS_BLOCKING): ditto. * thread.c (rb_threadptr_execute_interrupts): don't process interrupt if it is masked. [Bug #6009] [ruby-core:42524] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26split trap interrupt and async interruptkosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* vm_core.h (rb_thread_struct): added 'in_trap' member for markingkosaki
running trap handler. * signal.c (signal_exec): turn on in_trap when running trap. * thread.c (Init_Thread, thread_create_core): initialize in_trap when creating new threads. * thread.c (thread_join_m): raise ThreadError when running trap handler.Bug [#6416][ruby-core:44956] * test/ruby/test_thread.rb (test_thread_join_in_trap): new test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24* thread.c (thread_create_core): don't use th->thread_id beforekosaki
initialized. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20* vm_trace.c: add two methods:ko1
(1) TracePoint#return_value which returns return value on the :return and :c_return event. (2) TracePoint#raised_exception which returns raised exception value on the :raise event. Eeach methods raise RuntimeError if it is called at unsupported event. Please review and give us feedback until next preview release (Dec/2012) of Ruby 2.0.0. * insns.def, vm.c, vm_eval.c, vm_insnhelper.c, eval.c, thread.c: ditto. * vm_trace.c, vm_core.h: move definition of rb_trace_arg_t from vm_trace.c to vm_core.h. Caller fills rb_trace_arg_t and pass the pointer of this variable. * test/ruby/test_settracefunc.rb: fix tests to test this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e