summaryrefslogtreecommitdiff
path: root/thread.c
AgeCommit message (Collapse)Author
2012-09-10thread.c: staticnobu
* thread.c (patrol_thread): should be static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09* thread.c (rb_mutex_lock): stop multiple threads usekosaki
pthread_cond_timedwait() concurrently. [Bug #6278] [ruby-core:44275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20vm_insnhelper.c: iclass as klass in cfpnobu
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp but not included modules. [ruby-core:47241] [Bug #6891] * vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow proper ancestors. [ruby-core:47241] [Bug #6891] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16* vm_trace.c, vm_core.h: simplify tracing mechanism.ko1
(1) add rb_hook_list_t data structure which includes hooks, events (flag) and `need_clean' flag. If the last flag is true, then clean the hooks list. In other words, deleted hooks are contained by `hooks'. Cleanup process should run before traversing the list. (2) Change check mechanism See EXEC_EVENT_HOOK() in vm_core.h. (3) Add `raw' hooks APIs Normal hooks are guarded from exception by rb_protect(). However, this protection is overhead for too simple functions which never cause exceptions. `raw' hooks are executed without protection and faster. Now, we only provide registration APIs. All `raw' hooks are kicked under protection (same as normal hooks). * include/ruby/ruby.h: remove internal data definition and macros. * internal.h (ruby_suppress_tracing), vm_trace.c: rename ruby_suppress_tracing() to rb_suppress_tracing() and remove unused function parameter. * parse.y: fix to use renamed rb_suppress_tracing(). * thread.c (thread_create_core): no need to set RUBY_VM_VM. * vm.c (mark_event_hooks): move definition to vm_trace.c. * vm.c (ruby_vm_event_flags): add a global variable. This global variable represents all of Threads and VM's event masks (T1#events | T2#events | ... | VM#events). You can check the possibility kick trace func or not with ruby_vm_event_flags. ruby_vm_event_flags is maintained by vm_trace.c. * cont.c (fiber_switch, rb_cont_call): restore tracing status. [Feature #4347] * test/ruby/test_continuation.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15* vm_trace.c: separate trace_func related functions fromko1
thread.c. * thread.c: ditto. * common.mk: add vm_trace.o. * inits.c: call Init_vm_trace(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-29* thread.c (thread_create_core): hide th->async_errinfo_mask_stack fromnagachika
ObjectSpace.each_object. refix of r36539. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-29* thread.c (Init_Thread): does not need to set klassktsj
explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25* thread.c (thread_create_core, Init_Thread): hidenagachika
th->async_errinfo_queue and th->async_errinfo_mask_stack from ObjectSpace.each_object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-22* thread.c (rb_threadptr_execute_interrupts_common): increasenaruse
running_time_us on THREAD_TO_KILL like on THREAD_RUNNABLE. This cause not to siwtch from a thread which is to be killed on FreeBSD and Mac OS X. see also the test. This issue maybe exist for long time but happens after r36430. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19* thread.c (rb_thread_s_control_interrupt,ko1
rb_thread_s_check_interrupt): added for Thread.control_intgerrupt and Thread.check_interrupt. See details on rdoc. I'll make an ticket for this feature. * test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt. * thread.c (rb_threadptr_raise): make a new exception object even if argc is 0. * thread.c (rb_thread_kill): kill thread immediately if target thread is current thread. * vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added. CHECK_INTS while/after blocking operation. * vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr. * cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS(). * eval.c (ruby_cleanup): ditto. * insns.def: ditto. * process.c (rb_waitpid): ditto. * vm_eval.c (vm_call0): ditto. * vm_insnhelper.c (vm_call_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19thread.c: remove deprecatednobu
* thread.c (rb_gc_mark_threads): remove deprecated function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18* thread.c (rb_thread_call_without_gvl2): added.ko1
it can skip last CHECK_INTS. See document for more details. Document about it was updated a bit. * include/ruby/thread.h (decl. of rb_thread_call_without_gvl2): added. * thread.c (rb_thread_call_with_gvl): remove "EXPERIMENTAL!" warning from a document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18* thread.c: fix last commit miss.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18* thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.ko1
Async events such as an exception throwed by Thread#raise, Thread#kill and thread termination (after main thread termination) will be queued to th->async_errinfo_queue. - clear: clear the queue. - enque: enque err object into queue. - deque: deque err object from queue. - active_p: return 1 if the queue should be checked. rb_thread_t#thrown_errinfo was removed. * vm_core.h: add declarations of rb_threadptr_async_errinfo_*. remove rb_thread_t#thrown_errinfo field and add rb_thread_t#async_errinfo_queue (queue body: Array), rb_thread_t#async_errinfo_queue_checked (flag), rb_thread_t#async_errinfo_mask_stack(Array, not used yet). * vm.c (rb_thread_mark): fix a mark function. * cont.c (rb_fiber_start): enque an error. * process.c (after_fork): clear async errinfo queue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10rb_thread_call_without_gvlnobu
* include/ruby/thread.h: new header file for thread stuff. * thread.c (rb_thread_call_without_gvl): export. [Feature#4328] returns void* instead of VALUE. [Feature #5543] * thread.c (rb_thread_blocking_region): deprecate. [ruby-core:46295] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-06thread.c: unsignednobu
* thread.c (rb_thread_shield_waiting_{inc,dec}): should be unsigned. int is large enough since ruby requires it to be 32bit at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-06ThreadShield: check waiting countnobu
* thread.c (rb_thread_shield_waiting_{inc,dec}): check waiting count. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-05* thread.c: fix typo.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-05ThreadShieldnobu
* thread.c (ThreadShield): rename from Barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-04thread.c: fix rdocnobu
* thread.c (rb_thread_blocking_region): fix typo and the description in "Safe C API". ruby_xmalloc(), ruby_xrealloc() never try acquire GVL automatically unless GC runs, but had race condtions without GVL acquired until r36284. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02* thread.c (rb_thread_aref): add explanation for why Thread#[] andakr
Thread#[]= are fiber-local and not thread-local. reported by Julien A. [ruby-core:41606] [ruby-trunk - Bug #5750] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11* vm_core.h: remove lfp (local frame pointer) and renameko1
dfp (dynamic frame pointer) to ep (environment pointer). This change make VM `normal' (similar to other interpreters). Before this commit: Each frame has two env pointers lfp and dfp. lfp points local environment which is method/class/toplevel frame. lfp[0] is block pointer. dfp is block local frame. dfp[0] points previous (parent) environment pointer. lfp == dfp when frame is method/class/toplevel. You can get lfp from dfp by traversing previous environment pointers. After this commit: Each frame has only `ep' to point respective enviornoment. If there is parent environment, then ep[0] points parent envioenment (as dfp). If there are no more environment, then ep[0] points block pointer (as lfp). We call such ep as `LEP' (local EP). We add some macros to get LEP and to detect LEP or not. In short, we replace dfp and lfp with ep and LEP. rb_block_t and rb_binding_t member `lfp' and `dfp' are removed and member `ep' is added. rename rb_thread_t's member `local_lfp' and `local_svar' to `root_lep' and `root_svar'. (VM_EP_PREV_EP(ep)): get previous environment pointer. This macro assume that ep is not LEP. (VM_EP_BLOCK_PTR(ep)): get block pointer. This macro assume that ep is LEP. (VM_EP_LEP_P(ep)): detect ep is LEP or not. (VM_ENVVAL_BLOCK_PTR(ptr)): make block pointer. (VM_ENVVAL_BLOCK_PTR_P(v)): detect v is block pointer. (VM_ENVVAL_PREV_EP_PTR(ptr)): make prev environment pointer. (VM_ENVVAL_PREV_EP_PTR_P(v)): detect v is prev env pointer. * vm.c: apply above changes. (VM_EP_LEP(ep)): get LEP. (VM_CF_LEP(cfp)): get LEP of cfp->ep. (VM_CF_PREV_EP(cfp)): utility function VM_EP_PREV_EP(cfp->ep). (VM_CF_BLOCK_PTR(cfp)): utility function VM_EP_BLOCK_PTR(cfp->ep). * vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, insns.def: apply above changes. * cont.c: ditto. * eval.c, eval_intern.h: ditto. * proc.c: ditto. * thread.c: ditto. * vm_dump.c: ditto. * vm_exec.h: fix function name (on vm debug mode). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03* thread.c (vm_living_thread_num): suppress a warning.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23use RB_TYPE_P() instead of comparison of TYPE()nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17* thread.c, thread_pthread.c: Moved pthread-specific preprocessoryugui
hacks to thread_pthread.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17Imports Ruby's port to NativeClient (a.k.a NaCl).yugui
Patch by Google Inc. [ruby-core:45073]. * configure.in (RUBY_NACL): New M4 func to configure variables for NaCl. (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names of Pepper interface types. (BTESTRUBY): New variable to specify which ruby should be run on "make btest". NaCl can run the built binary by sel_ldr, but it need rbconfig.rb. So this variable is distinguished from $MINIRUBY. * thread_pthread.c: Disabled some features on NaCl. * io.c: ditto. * process.c: ditto. * signal.c: ditto. * file.c: ditto. * missing/flock.c: ditto. * nacl/pepper_main.c: An example implementation of Pepper application that embeds Ruby. * nacl/example.html: An example of web page that uses the Pepper application. * nacl/nacl-config.rb: Detects variants of NaCl SDK. * nacl/GNUmakefile.in: Makefile template for NaCl specific build process. * nacl/package.rb: script for packaging a NaCl-Ruby embedding application. * nacl/reate_nmf.rb: Wrapper script of create_nmf.py * dln.c (dln_load): Added a hack to call on NaCl. * util.c (ruby_getcwd): Path to the current directort is not available on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-11Revert r35622.naruse
It breaks bootstraptest/test_exception.rb:388. "* thread.c (rb_threadptr_execute_interrupts_common): th->errinfo is" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-11* thread.c (rb_threadptr_execute_interrupts_common): th->errinfo isnaruse
not Fixnum, but exception object. This causes test_signal_requiring of test/ruby/test_signal.rb fail if the sub process is killed on waiting IO in lex_io_gets in require itself, not sleep. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-28* vm_core.h (rb_thread_t#yielding): add a field.ko1
* thread.c (rb_thread_schedule_limits): set th#yielding while release GVL to yield CPU time. * thread.c (timer_thread_function): skip timer interrupt when th#yielding is true. This patch fixes r35480. * thread.c (rb_threadptr_execute_interrupts_common): revert a patch of r35480. * ChangeLog: add an extended memo of r35480. http://bugs.ruby-lang.org/projects/ruby-trunk/wiki/R35480_ExtendedMemo git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-26* thread.c (rb_threadptr_execute_interrupts_common):naruse
handle timer_interrupt only on the first loop for the case to avoid the infinite loop like following case: * there is 2 Ruby threads (3 pthreads) (1) main thread is waiting at gvl_yield:112 (native_cond_wait) (2) sub thread works (3) sub thread waits at gvl_yield:133 (native_mutex_unlock) (4) main thread works (5) main thread goes to gvl_acquire_common (6) main thread call rb_wakeup_timer_thread (7) timer thread set timer interrupt to the main thread (8) main thread works (9) main thread waits at gvl_acquire_common:64 (native_cond_wait) (10) sub tread works (11) set sub thread as the current thread (12) run Ruby thread (13) ...100ms (14) sub thread goes to rb_threadptr_execute_interrupts_common (15) sub thread call rb_thread_schedule_limits (16) sub thread call gvl_release_common (17) sub threads waits at gvl_yield:121 (native_cond_wait) (18) main threads works (19) main thread back to gvl_yield (20) set main thread as the current thread (21) main thread call gvl_yield (22) main thread waits at gvl_yield:112 (native_cond_wait) As described above, the main thread can't escape from rb_threadptr_execute_interrupts_common. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-23* thread.c (rb_check_deadlock): refine an error message of deadlockmame
detection. [ruby-core:44336] [Bug #6288] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29* thread.c (rb_threadptr_execute_interrupts_common): use definedusa
TIME_QUANTUM_USEC instead of a magic number. there is no meanings to use different values for checking interval of interruption and thread switching limits. cf. [Bug #6098] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13* thread.c (rb_mutex_unlock_th): simplified.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13* thread.c (rb_barrier_waiting): fix potential overflows.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-03* thread.c: changed documentation for "thread-local" variables.ayumin
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-30* thread.c (rb_barrier_waiting): save the number of waiting threadsnaruse
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-14* load.c (load_unlock): release loading barrier and then remove itnobu
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* load.c (load_lock): delete the loading barrier if it has beennobu
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-13* load.c (load_unlock): all threads requiring one file shouldnobu
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-11-15* io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: useakr
__linux__ macro for consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09* thread.c (do_select): fix cast, tv_sec is time_t.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03* thread.c (rb_fd_rcopy): suppress warnings on mingw32.nobu
* 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-09-29* use RB_TYPE_P which is optimized for constant types, instead ofnobu
comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-27* thread_pthread.c: make native_fd_select().kosaki
* 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* thread.c (do_select): remove cygwin specific hack. It's layerkosaki
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-14* thread.c (rb_fd_rcopy): added an argument guard.kosaki
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-12* thread.c (rb_thread_select): fix to ignore an argumentkosaki
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-09* thread.c (rb_thread_select): fix a typo to initialize efdsnobu
properly. [Bug #5299] [ruby-core:39380] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-30* thread.c (rb_thread_select): critical typo in r33117.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e