From: Robert Klemme Date: 2011-03-02T01:19:04+09:00 Subject: Re: question: threads behaviour On Tue, Mar 1, 2011 at 10:27 AM, Eric Wong wrote: > Raphael Bauduin wrote: >> As ruby threads are so called green threads, what's the behaviour when >> one thread is blocked on IO? > > They're only green threads on Ruby 1.8, 1.9 uses native threads. > >> If the thread is blocked on a system call, is the whole process, ie >> all threads blocked because the kernel scheduler considers the process >> as blocked on IO? Are there IOs blocking a thread without blocking the >> whole ruby process? > > 1.8 will schedule other threads if the blocking IO is for a socket/pipe > and uses the normal Ruby IO interfaces (or the extension author was > careful).  Filesystem I/O (including NFS) can block the entire process > in 1.8. Where do you take that from? AFAIK internally Ruby 1.8.* uses non blocking IO calls in combination with select() to be able to let other threads work while IO is under way. So: if IO blocks generally other threads continue to work - even on 1.8. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/