From: Jos Backus Date: 2012-07-06T05:35:31+09:00 Subject: Re: Green threads in 1.9.* ? --bcaec521620fb51fb504c41b10a0 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jul 5, 2012 at 1:22 PM, Eric Hodel wrote: > A more accurate picture of 1.9 is: > > The OS schedules threads to run on CPUs. > > The ruby VM has a global lock that only allows one thread to run ruby code > at a time (the GVL). The GVL is also held for execution inside C > extensions unless the author releases the GVL (most extensions release the > GVL for some part of their operation). > > Ruby schedules use of the GVL for threads created by the ruby VM. > > A Ruby thread may release the GVL to run non-ruby code. An example would > be performing a long calculation such as interacting with a DB, processing > zlib streams, XML parsing with libxml2, etc. Such tasks don't need to > communicate with the ruby VM so they can be running on separate CPUs at the > same time as the ruby VM. > > A Ruby thread will release the GVL when it performs a blocking operation > such as IO or other system calls. > > So the OS and the ruby VM cooperate on thread scheduling. If multiple > ruby threads do not need the GVL to run the OS does the majority of the > scheduling. If multiple ruby threads do need the GVL ruby does the > majority of the scheduling. > This would make a good FAQ entry, I think. Thanks, Eric. Jos -- Jos Backus jos at catnook.com --bcaec521620fb51fb504c41b10a0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Thu, Jul 5, 2012 at 1:22 PM, Eric Hodel <= drbrain@segment7.net> wrote:
Jos Backus
jos at catnook= .com

--bcaec521620fb51fb504c41b10a0--