summaryrefslogtreecommitdiff
path: root/thread.c
AgeCommit message (Collapse)Author
2022-06-17GVL Instrumentation API: add STARTED and EXITED eventsJean Boussier
[Feature #18339] After experimenting with the initial version of the API I figured there is a need for an exit event to cleanup instrumentation data. e.g. if you record data in a {thread_id -> data} table, you need to free associated data when a thread goes away. Notes: Merged: https://github.com/ruby/ruby/pull/6029
2022-06-15Restore rb_exec_recursive_outerJohn Hawthorn
This was a public method, so we should probably keep it. Notes: Merged: https://github.com/ruby/ruby/pull/6027
2022-06-15Remove MJIT worker thread (#6006)Takashi Kokubun
[Misc #18830] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-06-10Make method id explicit in rb_exec_recursive_outerJohn Hawthorn
Previously, because opt_aref and opt_aset don't push a frame, when they would call rb_hash to determine the hash value of the key, the initial level of recursion would incorrectly use the method id at the top of the stack instead of "hash". This commit replaces rb_exec_recursive_outer with rb_exec_recursive_outer_mid, which takes an explicit method id, so that we can make the hash calculation behave consistently. rb_exec_recursive_outer was documented as being internal, so I believe this should be okay to change. Notes: Merged: https://github.com/ruby/ruby/pull/6004
2022-06-10Add mid argument to exec_recursiveJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/6004
2022-05-24use `RUBY_DEBUG_LOG` instead of `thread_debug`Koichi Sasada
`thread_debug()` was introduced to print debug messages on `THREAD_DEBUG > 0` but `RUBY_DEBUG_LOG()` is more controllable. Notes: Merged: https://github.com/ruby/ruby/pull/5933
2022-05-24remove `NON_SCALAR_THREAD_ID` supportKoichi Sasada
`NON_SCALAR_THREAD_ID` shows `pthread_t` is non-scalar (non-pointer) and only s390x is known platform. However, the supporting code is very complex and it is only used for deubg print information. So this patch removes the support of `NON_SCALAR_THREAD_ID` and make the code simple. Notes: Merged: https://github.com/ruby/ruby/pull/5933
2022-05-17Delete autoload data from global features after autoload has completed. (#5910)Samuel Williams
* Update naming of critical section assertions macros. * Improved locking for autoload. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-15Fix various autoload race conditions. (#5898)Samuel Williams
* Add RUBY_VM_CRITICAL_SECTION for detecting unexpected context switch. * Prevent race between GC mark and autoload setup. * Protect race on autoload state. * Avoid potential race condition when allocating `autoload_featuremap`. * Add NEWS entry for autoload fixes. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-04-23introduce struct `rb_native_thread`Koichi Sasada
`rb_thread_t` contained `native_thread_data_t` to represent thread implementation dependent data. This patch separates them and rename it `rb_native_thread` and point it from `rb_thraed_t`. Now, 1 Ruby thread (`rb_thread_t`) has 1 native thread (`rb_native_thread`). Notes: Merged: https://github.com/ruby/ruby/pull/5836
2022-04-22rename thread internal namingKoichi Sasada
Now GVL is not process *Global* so this patch try to use another words. * `rb_global_vm_lock_t` -> `struct rb_thread_sched` * `gvl->owner` -> `sched->running` * `gvl->waitq` -> `sched->readyq` * `rb_gvl_init` -> `rb_thread_sched_init` * `gvl_destroy` -> `rb_thread_sched_destroy` * `gvl_acquire` -> `thread_sched_to_running` # waiting -> ready -> running * `gvl_release` -> `thread_sched_to_waiting` # running -> waiting * `gvl_yield` -> `thread_sched_yield` * `GVL_UNLOCK_BEGIN` -> `THREAD_BLOCKING_BEGIN` * `GVL_UNLOCK_END` -> `THREAD_BLOCKING_END` * removed * `rb_ractor_gvl` * `rb_vm_gvl_destroy` (not used) There are GVL functions such as `rb_thread_call_without_gvl()` yet but I don't have good name to replace them. Maybe GVL stands for "Greate Valuable Lock" or something like that. Notes: Merged: https://github.com/ruby/ruby/pull/5814
2022-04-14[DOC] Fix SymbolVariantsRelNotes linkS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5682
2022-03-30thread.c: Move double2hrtime and hrtime2double to hrtime.hYusuke Endoh
... to make them available in other places than thread.c Notes: Merged: https://github.com/ruby/ruby/pull/5703
2022-03-30Prefix ccan headers (#4568)Nobuyoshi Nakada
* Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-03-24Add ISEQ_BODY macroPeter Zhu
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation. Notes: Merged: https://github.com/ruby/ruby/pull/5698
2022-01-21Accurately report VM memsizeKevin Newton
Currently the calculation only counts the size of the struct. This commit adds the size of the associated st tables, id tables, and linked lists. Still missing is the size of the ractors and (potentially) the size of the object space. Notes: Merged: https://github.com/ruby/ruby/pull/5428
2022-01-19[wasm] add no thread variant for freestanding environmentYuta Saito
This implementation does nothing around preemptive context switching because there is no native thread. Notes: Merged: https://github.com/ruby/ruby/pull/5407
2022-01-19thread.c: put platform specific part in each impl fileYuta Saito
Notes: Merged: https://github.com/ruby/ruby/pull/5407
2022-01-18[Feature #18491] Drop support for HP-UXPeter Zhu
IA64 support was dropped in ticket #15894, so we can drop support for HP-UX. Notes: Merged: https://github.com/ruby/ruby/pull/5457
2022-01-13thread.c: Convert TAG_BREAK to a normal exception at thread top-levelYusuke Endoh
[Bug #18475] Notes: Merged: https://github.com/ruby/ruby/pull/5431
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>