summaryrefslogtreecommitdiff
path: root/thread.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge gc.h and internal/gc.hMatt Valentine-House2023-02-091-1/+1
| | | | [Feature #19425]
* Only emit circular dependency warning for owned thread shieldsJean byroot Boussier2023-02-081-0/+11
| | | | | | | | | | [Bug #19415] If multiple threads attemps to load the same file concurrently it's not a circular dependency issue. So we check that the existing ThreadShield is owner by the current fiber before warning about circular dependencies.
* Revert "Only emit circular dependency warning for owned thread shields"Jean byroot Boussier2023-02-061-11/+0
| | | | This reverts commit fa49651e05a06512e18ccb2f54a7198c9ff579de.
* Only emit circular dependency warning for owned thread shieldsJean Boussier2023-02-061-0/+11
| | | | | | | | | | [Bug #19415] If multiple threads attemps to load the same file concurrently it's not a circular dependency issue. So we check that the existing ThreadShield is owner by the current fiber before warning about circular dependencies.
* Remove unused struct member thgroup->groupMatt Valentine-House2023-01-201-2/+0
|
* Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)Samuel Williams2022-12-011-0/+2
|
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-8/+8
|
* Make pending_interrupt?(Exception) workYusuke Endoh2022-11-091-1/+1
| | | | | | A patch from katsu (Katsuhiro Ueno) [Bug #19110]
* Avoid missed wakeup with fiber scheduler and Fiber.blocking. (#6588)Samuel Williams2022-10-201-2/+2
| | | * Ensure that blocked fibers don't prevent valid wakeups.
* Add IO#timeout attribute and use it for blocking IO operations. (#5653)Samuel Williams2022-10-071-0/+11
|
* MJIT: Do not hang after forking with threadsTakashi Kokubun2022-09-111-7/+7
| | | | | | | | | | | First, rb_mjit_fork should call rb_thread_atfork to stop threads after fork in the child process. Unfortunately, we cannot use rb_fork_ruby to prevent this kind of mistakes because MJIT needs special handling of waiting_pid and mjit_pause/resume. Second, mjit_waitpid_finished should be checked regardless of trap_interrupt. It doesn't seem like the flag is not set when SIGCHLD is handled for an MJIT child process.
* Exit status macros need sys/wait.h on FreeBSDNobuyoshi Nakada2022-09-071-0/+4
|
* Do not fork the process on --mjit-waitTakashi Kokubun2022-09-061-1/+1
| | | | | fork is for parallel compilation, but --mjit-wait cancels it. It's more useful to not fork it for binding.irb, debugging, etc.
* Allow `RUBY_DEBUG_LOG` format to be emptyNobuyoshi Nakada2022-08-061-5/+5
| | | | | | | GCC warns of empty format strings, perhaps because they have no effects in printf() and there are better ways than sprintf(). However, ruby_debug_log() adds informations other than the format, this warning is not the case.
* Implement Queue#pop(timeout: sec)Jean Boussier2022-08-021-4/+31
| | | | | | | | | [Feature #18774] As well as `SizedQueue#pop(timeout: sec)` If both `non_block=true` and `timeout:` are supplied, ArgumentError is raised.
* Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu2022-07-261-7/+7
| | | | | | rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new.
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-519/+519
| | | | [Misc #18891]
* GVL Instrumentation: remove the EXITED count assertionJean Boussier2022-07-131-0/+1
| | | | | It's very flaky for some unknown reason. Something we have an extra EXITED event. I suspect some other test is causing this.
* Use VM Lock when mutating waiting threads listAaron Patterson2022-07-121-1/+5
| | | | | | | | | | | `rb_thread_wait_for_single_fd` needs to mutate the `waiting_fds` list that is stored on the VM. We need to delete the FD from the list before returning, and deleting from the list requires a VM lock (because the list is a global). [Bug #18816] [ruby-core:108771] Co-Authored-By: Alan Wu <alanwu@ruby-lang.org>
* Thread#value: handle threads killed by a forkJean Boussier2022-07-071-0/+4
| | | | | | | [Bug #18902] When a thread is killed because we forked, the `value` if left to `Qundef`. Returning it woudl crash the VM.
* GVL Instrumentation API: add STARTED and EXITED eventsJean Boussier2022-06-171-1/+0
| | | | | | | | [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.
* Restore rb_exec_recursive_outerJohn Hawthorn2022-06-151-0/+6
| | | | This was a public method, so we should probably keep it.
* Remove MJIT worker thread (#6006)Takashi Kokubun2022-06-151-0/+15
| | | [Misc #18830]
* Make method id explicit in rb_exec_recursive_outerJohn Hawthorn2022-06-101-2/+2
| | | | | | | | | | | | | | 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.
* Add mid argument to exec_recursiveJohn Hawthorn2022-06-101-6/+5
|
* 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
|