summaryrefslogtreecommitdiff
path: root/thread.c
AgeCommit message (Collapse)Author
2021-11-09Some codes replace to `RBOOL` macro (#5023)S.H
* Some code replace and using RBOOL macro * Fix indent * Using RBOOL in syserr_eqq function Notes: Merged-By: nobu <nobu@ruby-lang.org>
2021-11-08[Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu
This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult. Notes: Merged: https://github.com/ruby/ruby/pull/4363
2021-10-30Select including thread impl file at config timeYuta Saito
Notes: Merged: https://github.com/ruby/ruby/pull/5043
2021-10-27Prefer ANSI-style prototypes over old K&R-style definitionsNobuyoshi Nakada
2021-10-25Make Coverage suspendable (#4856)Yusuke Endoh
* Make Coverage suspendable Add `Coverage.suspend`, `Coverage.resume` and some methods. [Feature #18176] [ruby-core:105321] Notes: Merged-By: mame <mame@ruby-lang.org>
2021-10-24suppress warnings by parenthesizing unclear expressionsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5015
2021-10-03Using NIL_P macro instead of `== Qnil`S.H
Notes: Merged: https://github.com/ruby/ruby/pull/4925 Merged-By: nobu <nobu@ruby-lang.org>
2021-10-03Remove extraneous conversion to float [Bug #18236]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4927
2021-10-03Cast to void pointer to suppress -Wformat-pedantic in RUBY_DEBUG_LOGNobuyoshi Nakada
2021-09-28Move some function declaration to internal/io.hS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4901
2021-09-15Refactor and Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4837 Merged-By: nobu <nobu@ruby-lang.org>
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-08-03Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. This reverts commit 6505c77501f1924571b2fe620c5c7b31ede0cd22. Notes: Merged: https://github.com/ruby/ruby/pull/4689
2021-08-02Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4695 Merged-By: nobu <nobu@ruby-lang.org>
2021-07-28Revert "Fix potential hang when joining threads."Yusuke Endoh
This reverts commit 13f8521c630a15c87398dee0763e95f59c032a94. http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210727T230009Z.fail.html.gz http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210728T000009Z.fail.html.gz This revert is to confirm whether the commit is the cause. If the failures consistently occur after this revert, I'll reintroduce the commit.
2021-07-27Predefine recursive key IDNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4684
2021-07-27Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. Notes: Merged: https://github.com/ruby/ruby/pull/4660
2021-07-25Distinguish signal and timeout [Bug #16608]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4256
2021-07-01Replace copy coroutine with pthread implementation.Samuel Williams
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-06-24Reduce repeated same codeNobuyoshi Nakada
2021-06-22Deprecate and rework old (fd) centric functions.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4592
2021-06-17Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
2021-06-14Wake up join list within thread EC context. (#4471)Samuel Williams
* Wake up join list within thread EC context. * Consume items from join list so that they are not re-executed. If `rb_fiber_scheduler_unblock` raises an exception, it can result in a segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC which initially caused an infinite loop because on exception will retry. We explicitly remove items from the thread's join list to avoid this situation. * Verify the required scheduler interface. * Test several scheduler hooks methods with broken `unblock` implementation. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-06-03Suppress clobbered warnings on Travis-CI ppc64le-linuxNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4550 Merged-By: nobu <nobu@ruby-lang.org>
2021-06-01Make `Thread#native_thread_id` not-implemented if unsupportedNobuyoshi Nakada
Raise `NotImplementedError` on unsupported platforms regardless the argument consistently.
2021-05-26Add Thread#native_thread_id [Feature #17853]NARUSE, Yui
2021-04-08Document how to handle kill/terminate interrupts in Thread.handle_interruptJeremy Evans
The kill/terminate interrupts are internally handled not as Exception instances, but as integers. So using Exception doesn't handle these interrupts, but Object does. You can use Integer if you only want to handle kill/terminate interrupts, but that's probably more of an implementation detail, while handling Object should work regardless of the implementation. Fixes [Bug #15735]
2021-03-09Destroy VM-wise locks before freeing [Bug #15852]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4249
2021-03-07Make Ractor stdio belonging to the Ractor [Bug #17672]Nobuyoshi Nakada
Defer making ractor stdio until ractor started. Before ractor started, created objects belong to the caller ractor instead of the created ractor. Notes: Merged: https://github.com/ruby/ruby/pull/4241 Merged-By: nobu <nobu@ruby-lang.org>
2021-02-10Don't document that Thread#group can return nilJeremy Evans
Thread's are assigned a group at initialization, and no API exists for them to unassign them from a group without assigning them to another group. Fixes [Bug #17505] Notes: Merged: https://github.com/ruby/ruby/pull/4163
2021-02-09Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams
* Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-02-05unblock thread is only for main ractor.Koichi Sasada
other ractors should not have a unblock thread. This patch fixes 6f727853cee41195b67ee5d793c1ac23fe1a6ae0.
2021-02-03only main thread can modify vm->ubf_async_safeKoichi Sasada
vm->ubf_async_safe is VM global resource and only main thread can manipulate it. [Bug #17482] Notes: Merged: https://github.com/ruby/ruby/pull/4147
2021-01-19Replace "iff" with "if and only if"Gannon McGibbon
iff means if and only if, but readers without that knowledge might assume this to be a spelling mistake. To me, this seems like exclusionary language that is unnecessary. Simply using "if and only if" instead should suffice. Notes: Merged: https://github.com/ruby/ruby/pull/4035
2020-12-24introduce rb_ractor_atfork()Koichi Sasada
to reset main ractor at fork().
2020-12-23Revert "need to clear blocking cnt at fork (child process)"Koichi Sasada
This reverts commit 0dd4896175f95c4c2a26d91a97b9fcb9a74cc0c6. It breaks the tests on RUBY_DEBUG=1.
2020-12-23need to clear blocking cnt at fork (child process)Koichi Sasada
2020-12-22fix to use rb_ractor_id()Koichi Sasada
Catch up recent changes on USE_RUBY_DEBUG_LOG=1.
2020-12-14Introduce negative method cacheKoichi Sasada
pCMC doesn't have negative method cache so this patch implements it. Notes: Merged: https://github.com/ruby/ruby/pull/3892
2020-12-07fix Thread's interrupt and Ractor#take issueKoichi Sasada
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.
2020-12-05Protoized old pre-ANSI K&R style definitionsNobuyoshi Nakada
2020-12-05Proposed method for dealing with stack locals which have non-local lifetime.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3624
2020-11-25show the error message before Ractor.yieldKoichi Sasada
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().
2020-11-18fix public interfaceKoichi Sasada
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) Notes: Merged: https://github.com/ruby/ruby/pull/3775
2020-11-11Threads in a ractor will be killed with the ractorKoichi Sasada
If a terminating ractor has child threads, then kill all child threads. Notes: Merged: https://github.com/ruby/ruby/pull/3754
2020-11-11introduce USE_VM_CLOCK for windows.Koichi Sasada
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. Notes: Merged: https://github.com/ruby/ruby/pull/3754
2020-11-07Rename to `Fiber#set_scheduler`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3742
2020-10-30sync vm->waiting_fds correctly.Koichi Sasada
vm->waiting_fds is global resource so we need to lock it correctly. (forgot to sync one place)
2020-10-28Add Thread.ignore_deadlock accessorJeremy Evans
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] Notes: Merged: https://github.com/ruby/ruby/pull/3710 Merged-By: jeremyevans <code@jeremyevans.net>