From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 70E001B60168 for ; Sun, 2 Apr 2017 11:35:33 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 85762B5D8BB for ; Sun, 2 Apr 2017 12:12:28 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id E8A5418CC883 for ; Sun, 2 Apr 2017 12:12:28 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B4396120726; Sun, 2 Apr 2017 12:12:27 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org X-Greylist: delayed 418 seconds by postgrey-1.34 at neon; Sun, 02 Apr 2017 12:12:24 JST Received: from sakura3.atdot.net (ik1-326-23156.vs.sakura.ne.jp [153.126.180.160]) by neon.ruby-lang.org (Postfix) with ESMTP id A1DAA1206EA for ; Sun, 2 Apr 2017 12:12:24 +0900 (JST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by sakura3.atdot.net (Postfix) with ESMTP id C7FC53A37CF; Sun, 2 Apr 2017 12:05:25 +0900 (JST) To: Ruby developers References: <20170402011414.AEA9B64CEE@svn.ruby-lang.org> <8a2b82e3-dc07-1945-55f9-5a474e89130b@ruby-lang.org> <20170402023514.GB30476@dcvr> From: SASADA Koichi Message-ID: <76459664-9857-4244-7d43-79b24e737efc@atdot.net> Date: Sun, 2 Apr 2017 12:05:25 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170402023514.GB30476@dcvr> X-ML-Name: ruby-core X-Mail-Count: 80532 Subject: [ruby-core:80532] Re: [ruby-cvs:65407] normal:r58236 (trunk): thread.c: comments on M:N threading [ci skip] X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" On 2017/04/02 11:35, Eric Wong wrote: > However, to spawn native threads: > > If a Thread uses existing GVL release C-API, then the _next_ > Thread.new call will create a native thread (and future > Thread.new will be subclass of Fiber in new native thread). > > So, in pseudo code: > > class Thread < Fiber > def self.new > case Thread.current[:gvl_state] > when :none > # default > super # M += 1 > when :released > # this is set by BLOCKING_REGION GVL release > # only allow a user-level thread to spawn one new native thread > Thread.current[:gvl_state] = :spawned > > NativeThread.new { Thread.new } # N += 1 > when :spawned > # We already spawned on native thread from this user-level > # thread, only spawn new user-level thread for now. > super # M += 1 > end > end > end > > Current GVL release operations will change > Thread.current[:gvl_state] from :none -> :released Sorry I can't understand the basic of your idea with mixing Threads and Fibers. Maybe you need to define more about the model. Our plan is not mixing Threads and Fibers, so that (hopefully) there are no problem. Thanks, Koichi -- // SASADA Koichi at atdot dot net