Marc, How long lived is each of these tasks? Are we talking seconds or weeks? Is there a user-facing aspect to this or is throughput the variable that you're wanting to optimize? When you say "fairly CPU intensive", doe sthis mean that when one of these tasks runs you see (from sar/mpstat) that one of your CPUs is pinned? Peter On Oct 29, 2009, at 10:56 AM, Marc Hoeppner wrote: > Hi, > > I've been reading around a bit but couldn't find a solution that > worked, > so here goes: > > I am running ruby 1.8 and want to make full use of a quad core CPU > (64bit, Ubuntu) in a task that lends itself to multithreading/ > multicore > use. > > It's basically an array of objects that are each use in a fairly CPU > intensive job, so I figured I could have 4 of them run at the same > time > , one on each CPU. > > BUT... > > The only reasonably understandably suggestion looked something like: > > ---- > threads = 4 > my_array = [something_here] > > threads.times do > Process.fork(a_method(my_array.shift)) > end > > my_array.each do |object| > Process.wait(0) > Process.fork(a_method(object)) > end > --- > > But this still only used one CPU (and looks a bit ugly..). Is that > some > limitation of ruby (v 1.8 specifically) or am I doing something wrong? > > Cheers, > > Marc > -- > Posted via http://www.ruby-forum.com/. >