[#89806] [Ruby trunk Bug#15306] Generate prelude.c using miniruby — v.ondruch@...
Issue #15306 has been reported by vo.x (Vit Ondruch).
3 messages
2018/11/15
[ruby-core:89909] Re: Thread::Light patch against r65832
From:
Eric Wong <normalperson@...>
Date:
2018-11-20 15:15:28 UTC
List:
ruby-core #89909
Koichi Sasada <ko1@atdot.net> wrote:
> On 2018/11/20 17:44, Eric Wong wrote:
> > Mutex and ConditionVariable are NOT scheduling points for
> > Thread::Light switching; however they may process signal
> > handling and handle I/O dispatch for other native threads.
>
> Why not?
> How to synchronize multiple Thread::Light instances (lthreads here)?
I'm not sure how deadlock detection would work, and I don't
think there is data race there.
Main synchronization should be Queue/SizedQueue (like "mailbox"
in actor model).
But I think this is a good change to maintain compatibility
and avoid inadvertant switching:
diff --git a/vm_core.h b/vm_core.h
index 9e10b321da..2244afb524 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1842,24 +1842,27 @@ static inline int
rb_tl_switchable(const rb_execution_context_t *ec)
{
const rb_thread_t *th = rb_ec_thread_ptr(ec);
/* dangerous, don't allow switching inside trap handler: */
if (ec->interrupt_mask & TRAP_INTERRUPT_MASK) return 0;
+ /* don't switch if a Mutex is held */
+ if (th->keeping_mutexes) return 0;
+
/* auto-fibers can switch away to root fiber */
if (rb_tl_sched_p(ec)) return 1;
/* no auto-fibers, yet, but we can create and switch to them */
if (!th->root_fiber) return 1;
/* root fiber can switch to auto-fibers, because ensure works */
if (th->root_fiber == ec->fiber_ptr) return 1;
/*
* no auto-switching away from regular Fibers because they lack
* ensure support: https://bugs.ruby-lang.org/issues/595
*/
return 0;
}
/* tracer */
(Gotta run, back in 16 hours maybe?)
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>