aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
Commit message (Collapse)AuthorAgeFilesLines
* introduce rb_ractor_atfork()Koichi Sasada2020-12-241-5/+3
| | | | to reset main ractor at fork().
* Revert "need to clear blocking cnt at fork (child process)"Koichi Sasada2020-12-231-2/+1
| | | | | | This reverts commit 0dd4896175f95c4c2a26d91a97b9fcb9a74cc0c6. It breaks the tests on RUBY_DEBUG=1.
* need to clear blocking cnt at fork (child process)Koichi Sasada2020-12-231-1/+2
|
* fix to use rb_ractor_id()Koichi Sasada2020-12-221-1/+1
| | | | Catch up recent changes on USE_RUBY_DEBUG_LOG=1.
* Introduce negative method cacheKoichi Sasada2020-12-141-0/+2
| | | | pCMC doesn't have negative method cache so this patch implements it.
* fix Thread's interrupt and Ractor#take issueKoichi Sasada2020-12-071-0/+3
| | | | | | | | | Thread's interrupt set Ractor's wakeup_status as interrupted, but the status remains next Ractor communication API. This patch makes to ignore the previous interrupt state. [Bug #17366] Also this patch solves the Thread#kill and Ractor#take issues.
* Protoized old pre-ANSI K&R style definitionsNobuyoshi Nakada2020-12-051-1/+1
|
* Proposed method for dealing with stack locals which have non-local lifetime.Samuel Williams2020-12-051-7/+8
|
* show the error message before Ractor.yieldKoichi Sasada2020-11-251-6/+7
| | | | | | | | | | | Ractor's error will be printed if Thread#report_on_exception is true (default), and error message is used. Without this patch, the exception object is sent by Ractor.yield and it can be shared with another ractor. http://ci.rvm.jp/results/trunk-random3@phosphorus-docker/3269368 To prevent such sharing, show errors befor Ractor.yield().
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* Threads in a ractor will be killed with the ractorKoichi Sasada2020-11-111-7/+7
| | | | | If a terminating ractor has child threads, then kill all child threads.
* introduce USE_VM_CLOCK for windows.Koichi Sasada2020-11-111-10/+0
| | | | | | | | | | | | | | | | The timer function used on windows system set timer interrupt flag of current main ractor's executing ec and thread can detect the end of time slice. However, to set all ec->interrupt_flag for all running ractors, it is requires to synchronize with other ractors. However, timer thread can not acquire the ractor-wide lock because of some limitation. To solve this issue, this patch introduces USE_VM_CLOCK compile option to introduce rb_vm_t::clock. This clock will be incremented by the timer thread and each thread can check the incrementing by comparison with previous checked clock. At last, on windows platform this patch introduces some overhead, but I think there is no critical performance issue because of this modification.
* Rename to `Fiber#set_scheduler`.Samuel Williams2020-11-071-82/+3
|
* sync vm->waiting_fds correctly.Koichi Sasada2020-10-301-1/+7
| | | | | vm->waiting_fds is global resource so we need to lock it correctly. (forgot to sync one place)
* Add Thread.ignore_deadlock accessorJeremy Evans2020-10-281-1/+51
| | | | | | | | | | Setting this to true disables the deadlock detector. It should only be used in cases where the deadlock could be broken via some external means, such as via a signal. Now that $SAFE is no longer used, replace the safe_level_ VM flag with ignore_deadlock for storing the setting. Fixes [Bug #13768]
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-7/+4
|
* Add Ractor#receive and Ractor.receive and use it in all placesBenoit Daloze2020-10-101-1/+1
| | | | * Keep Ractor#recv/Ractor.recv as an alias for now.
* Don't use `th->scheduler` directly because it's not always valid to do so.Samuel Williams2020-10-011-2/+4
|
* rb_thread_scheduler is no longer usedNobuyoshi Nakada2020-10-011-0/+2
|
* Remove `Thread.scheduler` from public interface.Samuel Williams2020-10-011-1/+1
| | | | | | It's implementation is equivalent to: Thread.current.scheduler unless Thread.current.blocking?
* Make Thread#join always convert its argument, as before 70f08f1eedBenoit Daloze2020-09-211-0/+11
|
* Make it clear the first field of join_arg is the waiting threadBenoit Daloze2020-09-211-11/+11
| | | | * And not some list of sort.
* Make `Thread#join` non-blocking.Samuel Williams2020-09-211-112/+137
|
* When setting current thread scheduler to nil, invoke `#close`.Samuel Williams2020-09-211-4/+6
|
* Call scheduler.block instead of scheduler.kernel_sleep for blocking ↵Benoit Daloze2020-09-171-3/+3
| | | | | | | Queue/SizedQueue operations * scheduler.unblock was already already called before but with no corresponding scheduler.block * add test that Queue#pop makes the scheduler wait until it gets an element.
* restart Ractor.select on intteruptKoichi Sasada2020-09-151-0/+6
| | | | | signal can interrupt Ractor.select, but if there is no exception, Ractor.select should restart automatically.
* Add support for Queue & SizedQueue.Samuel Williams2020-09-141-2/+7
|
* Make Mutex per-Fiber instead of per-ThreadBenoit Daloze2020-09-141-5/+6
| | | | | | | | | * Enables Mutex to be used as synchronization between multiple Fibers of the same Thread. * With a Fiber scheduler we can yield to another Fiber on contended Mutex#lock instead of blocking the entire thread. * This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby. * [Feature #16792]
* Standardised scheduler interface.Samuel Williams2020-09-141-41/+3
|
* Add `rb_thread_current_scheduler()`.Samuel Williams2020-09-141-0/+6
|
* Removed Thread#safe_levelHiroshi SHIBATA2020-09-111-18/+0
|
* If the GC runs before the Mutex's are initialised then we get a crash in ↵Matt Valentine-House2020-09-101-3/+10
| | | | | | pthread_mutex_lock. It is possible for GC to run during initialisation due to objects being allocated
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-207/+374
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* procnames-start-lines [ci skip]Nobuyoshi Nakada2020-08-171-3/+6
|
* Rename `rb_current_thread_scheduler` to `rb_thread_scheduler_if_nonblocking`.Samuel Williams2020-07-201-7/+8
| | | | | Correctly capture thread before releasing GVL and pass as argument to `rb_thread_scheduler_if_nonblocking`.
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities.
* exec_recursive: do not goto into a branch卜部昌平2020-06-291-4/+6
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* compile.c: Improve branch coverage instrumentation [Bug #16967]Yusuke Endoh2020-06-201-14/+25
| | | | | | | | | | | | | | Formerly, branch coverage measurement counters are generated for each compilation traverse of the AST. However, ensure clause node is traversed twice; one is for normal-exit case (the resulted bytecode is embedded in its outer scope), and the other is for exceptional case (the resulted bytecode is used in catch table). Two branch coverage counters are generated for the two cases, but it is not desired. This changeset revamps the internal representation of branch coverage measurement. Branch coverage counters are generated only at the first visit of a branch node. Visiting the same node reuses the already-generated counter, so double counting is avoided.
* Make Thread#thread_variable? similar to #thread_variable_getJeremy Evans2020-05-251-6/+3
| | | | | | | | | | | | Don't use rb_check_id, which only works for pinned symbols. Switch inadvertent creation test for thread_variable? to only check for pinned symbols, same as thread_variable_get and thread_variable_set. Make key variable name in thread_local_set match thread_local_get and thread_variable?. Fixes [Bug #16906]
* Thread scheduler for light weight concurrency.Samuel Williams2020-05-141-2/+107
|
* Thread#backtrace may return nil [ci skip]Kazuhiro NISHIYAMA2020-05-121-1/+1
|
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* should check pending interrupts correctly.Koichi Sasada2020-04-091-1/+17
| | | | | | | | | | | | rb_uninterruptible() disables any interrupts using handle_interrupt feature (This function is used by `p`). After this function, pending interrupts should be checked correctly, however there is no chance to setup interrupt flag of working threads, it means that nobody checks pending interrupts. For example, it ignores terminate signal delivered at the end of main thread and program can't stop. This patch set interrupt flag if there are pending interrupts.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* check flags passed to rb_nogvl()Koichi Sasada2020-03-261-1/+1
| | | | | | RB_NOGVL_UBF_ASYNC_SAFE is wrongly specified because flags is not checked. [Bug #15499] 23444302
* fix arity mismatch卜部昌平2020-02-201-1/+1
| | | | | This is a ruby method with arity zero. Which means, this function takes one argument (that is self).
* more on NULL versus functions.卜部昌平2020-02-071-3/+3
| | | | | | Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
* st_delete_wrap is no longer usedNobuyoshi Nakada2020-01-111-6/+0
|
* Let execution context local storage be an ID tableLourens Naudé2020-01-111-17/+18
|