summaryrefslogtreecommitdiff
path: root/thread.c
Commit message (Collapse)AuthorAgeFilesLines
* use `RUBY_DEBUG_LOG` instead of `thread_debug`Koichi Sasada2022-05-241-141/+61
| | | | | `thread_debug()` was introduced to print debug messages on `THREAD_DEBUG > 0` but `RUBY_DEBUG_LOG()` is more controllable.
* remove `NON_SCALAR_THREAD_ID` supportKoichi Sasada2022-05-241-37/+2
| | | | | | | | | `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.
* Delete autoload data from global features after autoload has completed. (#5910)Samuel Williams2022-05-171-1/+1
| | | | | * Update naming of critical section assertions macros. * Improved locking for autoload.
* Fix various autoload race conditions. (#5898)Samuel Williams2022-05-151-0/+4
| | | | | | | | | | | * 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.
* introduce struct `rb_native_thread`Koichi Sasada2022-04-231-2/+2
| | | | | | | | | `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`).
* rename thread internal namingKoichi Sasada2022-04-221-20/+17
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* [DOC] Fix SymbolVariantsRelNotes linkS-H-GAMELINKS2022-04-141-1/+1
|
* thread.c: Move double2hrtime and hrtime2double to hrtime.hYusuke Endoh2022-03-301-40/+0
| | | | ... to make them available in other places than thread.c
* Prefix ccan headers (#4568)Nobuyoshi Nakada2022-03-301-25/+25
| | | | | | | | | | | | | * 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>
* Add ISEQ_BODY macroPeter Zhu2022-03-241-4/+4
| | | | | | 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.
* Accurately report VM memsizeKevin Newton2022-01-211-0/+15
| | | | | | 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.
* [wasm] add no thread variant for freestanding environmentYuta Saito2022-01-191-1/+1
| | | | | This implementation does nothing around preemptive context switching because there is no native thread.
* thread.c: put platform specific part in each impl fileYuta Saito2022-01-191-19/+0
|
* [Feature #18491] Drop support for HP-UXPeter Zhu2022-01-181-2/+0
| | | | | IA64 support was dropped in ticket #15894, so we can drop support for HP-UX.
* thread.c: Convert TAG_BREAK to a normal exception at thread top-levelYusuke Endoh2022-01-131-0/+3
| | | | [Bug #18475]
* Some codes replace to `RBOOL` macro (#5023)S.H2021-11-091-6/+1
| | | | | | | * Some code replace and using RBOOL macro * Fix indent * Using RBOOL in syserr_eqq function
* [Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu2021-11-081-1/+0
| | | | | This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult.
* Select including thread impl file at config timeYuta Saito2021-10-301-4/+2
|
* Prefer ANSI-style prototypes over old K&R-style definitionsNobuyoshi Nakada2021-10-271-2/+2
|
* Make Coverage suspendable (#4856)Yusuke Endoh2021-10-251-5/+18
| | | | | | | * Make Coverage suspendable Add `Coverage.suspend`, `Coverage.resume` and some methods. [Feature #18176] [ruby-core:105321]
* suppress warnings by parenthesizing unclear expressionsNobuyoshi Nakada2021-10-241-1/+1
|
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-1/+1
|
* Remove extraneous conversion to float [Bug #18236]Nobuyoshi Nakada2021-10-031-21/+14
|
* Cast to void pointer to suppress -Wformat-pedantic in RUBY_DEBUG_LOGNobuyoshi Nakada2021-10-031-1/+1
|
* Move some function declaration to internal/io.hS-H-GAMELINKS2021-09-281-5/+0
|
* Refactor and Using RBOOL macroS.H2021-09-151-13/+2
|
* Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS2021-09-111-1/+1
|
* Fix potential hang when joining threads.Samuel Williams2021-08-031-27/+48
| | | | | | | | | | | 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.
* Using RBOOL macroS.H2021-08-021-24/+10
|
* Revert "Fix potential hang when joining threads."Yusuke Endoh2021-07-281-17/+4
| | | | | | | | | | | 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.
* Predefine recursive key IDNobuyoshi Nakada2021-07-271-2/+1
|
* Fix potential hang when joining threads.Samuel Williams2021-07-271-4/+17
| | | | | | | | | 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.
* Distinguish signal and timeout [Bug #16608]Nobuyoshi Nakada2021-07-251-2/+4
|
* Replace copy coroutine with pthread implementation.Samuel Williams2021-07-011-11/+11
|
* Prefer qualified names under ThreadNobuyoshi Nakada2021-06-291-1/+1
|
* Reduce repeated same codeNobuyoshi Nakada2021-06-241-13/+9
|
* Deprecate and rework old (fd) centric functions.Samuel Williams2021-06-221-33/+0
|
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-5/+10
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
* Wake up join list within thread EC context. (#4471)Samuel Williams2021-06-141-79/+77
| | | | | | | | | | | | | | | * 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.
* Suppress clobbered warnings on Travis-CI ppc64le-linuxNobuyoshi Nakada2021-06-031-2/+3
|
* Make `Thread#native_thread_id` not-implemented if unsupportedNobuyoshi Nakada2021-06-011-0/+4
| | | | | Raise `NotImplementedError` on unsupported platforms regardless the argument consistently.
* Add Thread#native_thread_id [Feature #17853]NARUSE, Yui2021-05-261-0/+31
|
* Document how to handle kill/terminate interrupts in Thread.handle_interruptJeremy Evans2021-04-081-0/+2
| | | | | | | | | | | 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]
* Destroy VM-wise locks before freeing [Bug #15852]Nobuyoshi Nakada2021-03-091-7/+0
|
* Make Ractor stdio belonging to the Ractor [Bug #17672]Nobuyoshi Nakada2021-03-071-0/+9
| | | | | Defer making ractor stdio until ractor started. Before ractor started, created objects belong to the caller ractor instead of the created ractor.
* Don't document that Thread#group can return nilJeremy Evans2021-02-101-8/+2
| | | | | | | | 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]
* Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams2021-02-091-8/+8
| | | | | | | | | * 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.
* unblock thread is only for main ractor.Koichi Sasada2021-02-051-2/+2
| | | | | other ractors should not have a unblock thread. This patch fixes 6f727853cee41195b67ee5d793c1ac23fe1a6ae0.
* only main thread can modify vm->ubf_async_safeKoichi Sasada2021-02-031-3/+5
| | | | | | vm->ubf_async_safe is VM global resource and only main thread can manipulate it. [Bug #17482]
* Replace "iff" with "if and only if"Gannon McGibbon2021-01-191-1/+1
| | | | | | | 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.