Project

General

Profile

Actions

Feature #14717

closed

[PATCH] thread: allow disabling preempt

Added by normalperson (Eric Wong) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:86717]

Description

In some cases, it may be beneficial to disable preemptibility to
have more predictable behavior than increasing Thread#priority.
Threads with preempt disabled will run until they either:

a) encounter a thread blocking region
b) call Thread.pass

This allows native threads to act cooperatively without
being interrupted by other threads.

Thread#preemptible? => true or false
Thread#preemptible = (true|false)

I plan to implement timer-based switching to "auto-fiber/threadlet/thriber/whatever-name"
[Feature #13618] to minimize migration costs from Thread.

However, I think based on the discussion in [Feature #13618]; having
predictability of non-preemptible threads is beneficial. So implement it
for native Thread for now.

I will unify the behavior of [Feature #13618] with existing Thread.
I think green/native threads can be unified under Thread class similar to
how Fixnum/Bignum are both "Integer".


Files

0001-thread-allow-disabling-preempt.patch (4.16 KB) 0001-thread-allow-disabling-preempt.patch normalperson (Eric Wong), 04/27/2018 08:14 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0